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: FieldIncludeText → Field
Constructors
Name | Description |
---|---|
FieldIncludeText() | The default constructor. |
Properties
Name | Description |
---|---|
bookmark_name | Gets or sets the name of the bookmark in the document to include. |
display_result | Gets the text that represents the displayed field result. (Inherited from Field) |
encoding | Gets or sets the encoding applied to the data within the referenced file. |
end | Gets the node that represents the field end. (Inherited from Field) |
format | Gets a FieldFormat object that provides typed access to field’s formatting. (Inherited from Field) |
is_dirty | Gets 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_locked | Gets or sets whether the field is locked (should not recalculate its result). (Inherited from Field) |
locale_id | Gets or sets the LCID of the field. (Inherited from Field) |
lock_fields | Gets or sets whether to prevent fields in the included document from being updated. |
mime_type | Gets or sets the MIME type of the referenced file. |
namespace_mappings | Gets or sets the namespace mappings for XPath queries. |
result | Gets or sets text that is between the field separator and field end. (Inherited from Field) |
separator | Gets the node that represents the field separator. Can be None .(Inherited from Field) |
source_full_name | Gets or sets the location of the document using an IRI. |
start | Gets the node that represents the start of the field. (Inherited from Field) |
text_converter | Gets or sets the name of the text converter for the format of the included file. |
type | Gets the Microsoft Word field type. (Inherited from Field) |
xpath | Gets or sets XPath for the desired portion of the XML file. |
xsl_transformation | Gets or sets the location of XSL Transformation to format XML data. |
Methods
Name | Description |
---|---|
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 field_include_text():
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 = 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 = 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')
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
- module aspose.words.fields
- class Field