FieldIncludePicture class

FieldIncludePicture class

Implements the INCLUDEPICTURE field. To learn more, visit the Working with Fields documentation article.


Retrieves a picture and displays it as the field result.

Inheritance: FieldIncludePictureField


FieldIncludePicture()The default constructor.


display_resultGets the text that represents the displayed field result.
(Inherited from Field)
endGets the node that represents the field end.
(Inherited from Field)
formatGets a FieldFormat object that provides typed access to field’s formatting.
(Inherited from Field)
graphic_filterGets or sets the name of the filter for the format of the graphic that is to be inserted.
is_dirtyGets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document.
(Inherited from Field)
is_linkedGets or sets whether to reduce the file size by not storing graphics data with the document.
is_lockedGets or sets whether the field is locked (should not recalculate its result).
(Inherited from Field)
locale_idGets or sets the LCID of the field.
(Inherited from Field)
resize_horizontallyGets or sets whether to resize the picture horizontally from the source.
resize_verticallyGets or sets whether to resize the picture vertically from the source.
resultGets or sets text that is between the field separator and field end.
(Inherited from Field)
separatorGets the node that represents the field separator. Can be None.
(Inherited from Field)
source_full_nameGets or sets the location of the picture using an IRI.
startGets the node that represents the start of the field.
(Inherited from Field)
typeGets the Microsoft Word field type.
(Inherited from Field)


get_field_code()Returns text between field start and field separator (or field end if there is no separator). Both field code and field result of child fields are included.
(Inherited from Field)
get_field_code(include_child_field_codes)Returns text between field start and field separator (or field end if there is no separator).
(Inherited from Field)
remove()Removes the field from the document. Returns a node right after the field. If the field’s end is the last child of its parent node, returns its parent paragraph. If the field is already removed, returns None.
(Inherited from Field)
unlink()Performs the field unlink.
(Inherited from Field)
update()Performs the field update. Throws if the field is being updated already.
(Inherited from Field)
update(ignore_merge_format)Performs a field update. Throws if the field is being updated already.
(Inherited from Field)


Shows how to insert images using IMPORT and INCLUDEPICTURE fields.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# Below are two similar field types that we can use to display images linked from the local file system.
# 1 -  The INCLUDEPICTURE field:
field_include_picture = builder.insert_field(aw.fields.FieldType.FIELD_INCLUDE_PICTURE, True).as_field_include_picture()
field_include_picture.source_full_name = IMAGE_DIR + 'Transparent background logo.png'
self.assertRegex(field_include_picture.get_field_code(), ' INCLUDEPICTURE  .*')
# Apply the PNG32.FLT filter.
field_include_picture.graphic_filter = 'PNG32'
field_include_picture.is_linked = True
field_include_picture.resize_horizontally = True
field_include_picture.resize_vertically = True
# 2 -  The IMPORT field:
field_import = builder.insert_field(aw.fields.FieldType.FIELD_IMPORT, True).as_field_import()
field_import.source_full_name = IMAGE_DIR + 'Transparent background logo.png'
field_import.graphic_filter = 'PNG32'
field_import.is_linked = True
self.assertRegex(field_import.get_field_code(), ' IMPORT  .* \\\\c PNG32 \\\\d')
doc.update_fields() + 'Field.field_include_picture.docx')

See Also