FieldIncludeText class

FieldIncludeText class

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

Remarks

Inserts all or part of the text and graphics contained in another document.

Inheritance: FieldIncludeTextField

Constructors

NameDescription
FieldIncludeText()The default constructor.

Properties

NameDescription
bookmark_nameGets or sets the name of the bookmark in the document to include.
display_resultGets the text that represents the displayed field result.
(Inherited from Field)
encodingGets or sets the encoding applied to the data within the referenced file.
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)
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_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)
lock_fieldsGets or sets whether to prevent fields in the included document from being updated.
mime_typeGets or sets the MIME type of the referenced file.
namespace_mappingsGets or sets the namespace mappings for XPath queries.
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 document using an IRI.
startGets the node that represents the start of the field.
(Inherited from Field)
text_converterGets or sets the name of the text converter for the format of the included file.
typeGets the Microsoft Word field type.
(Inherited from Field)
xpathGets or sets XPath for the desired portion of the XML file.
xsl_transformationGets or sets the location of XSL Transformation to format XML data.

Methods

NameDescription
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)

Examples

Shows how to create an INCLUDETEXT field, and set its properties.

def test_field_include_text(self):

    doc = aw.Document()
    builder = aw.DocumentBuilder(doc)

    # Below are two ways to use INCLUDETEXT fields to display the contents of an XML file in the local file system.
    # 1 -  Perform an XSL transformation on an XML document:
    field_include_text = ExField.create_field_include_text(builder, MY_DIR + "CD collection data.xml", False, "text/xml", "XML", "ISO-8859-1")
    field_include_text.xsl_transformation = MY_DIR + "CD collection XSL transformation.xsl"

    builder.writeln()

    # 2 -  Use an XPath to take specific elements from an XML document:
    field_include_text = ExField.create_field_include_text(builder, MY_DIR + "CD collection data.xml", False, "text/xml", "XML", "ISO-8859-1")
    field_include_text.namespace_mappings = "xmlns:n='myNamespace'"
    field_include_text.xpath = "/catalog/cd/title"

    doc.update_fields()
    doc.save(ARTIFACTS_DIR + "Field.field_include_text.docx")

@staticmethod
def create_field_include_text(builder: aw.DocumentBuilder, source_full_name: str, lock_fields: bool, mime_type: str, text_converter: str, encoding: str) -> aw.fields.FieldIncludeText:
    """Use a document builder to insert an INCLUDETEXT field with custom properties."""

    field_include_text = builder.insert_field(aw.fields.FieldType.FIELD_INCLUDE_TEXT, True).as_field_include_text()
    field_include_text.source_full_name = source_full_name
    field_include_text.lock_fields = lock_fields
    field_include_text.mime_type = mime_type
    field_include_text.text_converter = text_converter
    field_include_text.encoding = encoding

    return field_include_text

See Also