FieldIncludeText
Contents
[
Hide
]FieldIncludeText class
Implements the INCLUDETEXT field.
To learn more, visit the Working with Fields documentation article.
public class FieldIncludeText : Field
Constructors
Name | Description |
---|---|
FieldIncludeText() | The default constructor. |
Properties
Name | Description |
---|---|
BookmarkName { get; set; } | Gets or sets the name of the bookmark in the document to include. |
DisplayResult { get; } | Gets the text that represents the displayed field result. |
Encoding { get; set; } | Gets or sets the encoding applied to the data within the referenced file. |
End { get; } | Gets the node that represents the field end. |
Format { get; } | Gets a FieldFormat object that provides typed access to field’s formatting. |
IsDirty { get; set; } | Gets or sets whether the current result of the field is no longer correct (stale) due to other modifications made to the document. |
IsLocked { get; set; } | Gets or sets whether the field is locked (should not recalculate its result). |
LocaleId { get; set; } | Gets or sets the LCID of the field. |
LockFields { get; set; } | Gets or sets whether to prevent fields in the included document from being updated. |
MimeType { get; set; } | Gets or sets the MIME type of the referenced file. |
NamespaceMappings { get; set; } | Gets or sets the namespace mappings for XPath queries. |
Result { get; set; } | Gets or sets text that is between the field separator and field end. |
Separator { get; } | Gets the node that represents the field separator. Can be null . |
SourceFullName { get; set; } | Gets or sets the location of the document using an IRI. |
Start { get; } | Gets the node that represents the start of the field. |
TextConverter { get; set; } | Gets or sets the name of the text converter for the format of the included file. |
virtual Type { get; } | Gets the Microsoft Word field type. |
XPath { get; set; } | Gets or sets XPath for the desired portion of the XML file. |
XslTransformation { get; set; } | Gets or sets the location of XSL Transformation to format XML data. |
Methods
Name | Description |
---|---|
GetFieldCode() | 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. |
GetFieldCode(bool) | Returns text between field start and field separator (or field end if there is no separator). |
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 null . |
Unlink() | Performs the field unlink. |
Update() | Performs the field update. Throws if the field is being updated already. |
Update(bool) | Performs a field update. Throws if the field is being updated already. |
Remarks
Inserts all or part of the text and graphics contained in another document.
Examples
Shows how to create an INCLUDETEXT field, and set its properties.
public void FieldIncludeText()
{
Document doc = new Document();
DocumentBuilder builder = new 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:
FieldIncludeText fieldIncludeText = CreateFieldIncludeText(builder, MyDir + "CD collection data.xml", false, "text/xml", "XML", "ISO-8859-1");
fieldIncludeText.XslTransformation = MyDir + "CD collection XSL transformation.xsl";
builder.Writeln();
// 2 - Use an XPath to take specific elements from an XML document:
fieldIncludeText = CreateFieldIncludeText(builder, MyDir + "CD collection data.xml", false, "text/xml", "XML", "ISO-8859-1");
fieldIncludeText.NamespaceMappings = "xmlns:n='myNamespace'";
fieldIncludeText.XPath = "/catalog/cd/title";
doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.INCLUDETEXT.docx");
}
/// <summary>
/// Use a document builder to insert an INCLUDETEXT field with custom properties.
/// </summary>
public FieldIncludeText CreateFieldIncludeText(DocumentBuilder builder, string sourceFullName, bool lockFields, string mimeType, string textConverter, string encoding)
{
FieldIncludeText fieldIncludeText = (FieldIncludeText)builder.InsertField(FieldType.FieldIncludeText, true);
fieldIncludeText.SourceFullName = sourceFullName;
fieldIncludeText.LockFields = lockFields;
fieldIncludeText.MimeType = mimeType;
fieldIncludeText.TextConverter = textConverter;
fieldIncludeText.Encoding = encoding;
return fieldIncludeText;
}
See Also
- class Field
- namespace Aspose.Words.Fields
- assembly Aspose.Words