Range

Range class

Represents a contiguous area in a document.

public class Range

Properties

Name Description
Bookmarks { get; } Returns a Bookmarks collection that represents all bookmarks in the range.
Fields { get; } Returns a Fields collection that represents all fields in the range.
FormFields { get; } Returns a FormFields collection that represents all form fields in the range.
StructuredDocumentTags { get; } Returns a StructuredDocumentTags collection that represents all structured document tags in the range.
Text { get; } Gets the text of the range.

Methods

Name Description
Delete() Deletes all characters of the range.
NormalizeFieldTypes() Changes field type values FieldType of FieldStart, FieldSeparator, FieldEnd in this range so that they correspond to the field types contained in the field codes.
Replace(Regex, string) Replaces all occurrences of a character pattern specified by a regular expression with another string.
Replace(string, string) Replaces all occurrences of a specified character string pattern with a replacement string.
Replace(Regex, string, FindReplaceOptions) Replaces all occurrences of a character pattern specified by a regular expression with another string.
Replace(string, string, FindReplaceOptions) Replaces all occurrences of a specified character string pattern with a replacement string.
ToDocument() Constructs a new fully formed document that contains the range.
UnlinkFields() Unlinks fields in this range.
UpdateFields() Updates the values of document fields in this range.

Remarks

The document is represented by a tree of nodes and the nodes provide operations to work with the tree, but some operations are easier to perform if the document is treated as a contiguous sequence of text.

Range is a “facade” interface that provide methods that treat the document or portions of the document as “flat” text regardless of the fact that the document nodes are stored in a tree-like object model.

Range does not contain any text or nodes, it is merely a view or “window” over a fragment of a document.

Examples

Shows how to get the text contents of all the nodes that a range covers.

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

builder.Write("Hello world!");

Assert.AreEqual("Hello world!", doc.Range.Text.Trim());

See Also