FieldInclude

FieldInclude class

Implements the INCLUDE field.

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

public class FieldInclude : Field

Constructors

NameDescription
FieldInclude()The default constructor.

Properties

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

Methods

NameDescription
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 INCLUDE field, and set its properties.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// We can use an INCLUDE field to import a portion of another document in the local file system.
// The bookmark from the other document that we reference with this field contains this imported portion.
FieldInclude field = (FieldInclude)builder.InsertField(FieldType.FieldInclude, true);
field.SourceFullName = MyDir + "Bookmarks.docx";
field.BookmarkName = "MyBookmark1";
field.LockFields = false;
field.TextConverter = "Microsoft Word";

Assert.True(Regex.Match(field.GetFieldCode(), " INCLUDE .* MyBookmark1 \\\\c \"Microsoft Word\"").Success);

doc.UpdateFields();
doc.Save(ArtifactsDir + "Field.INCLUDE.docx");

See Also