SubDocument Class
Defines a sub-document in a document.
Declaration
export class SubDocument
Inheritance
Properties
bookmarks Property
Provide access to the sub-document’s collection of bookmarks.
Declaration
get bookmarks(): BookmarkCollection<Bookmark>
Property Value
| Type | Description |
|---|---|
| BookmarkCollection<Bookmark> | A collection of bookmarks. |
fields Property
Provide access to the sub-document’s collection of fields.
Declaration
get fields(): FieldCollection
Property Value
| Type | Description |
|---|---|
| FieldCollection | A collection of fields. |
Remarks
var subDocument = richEdit.selection.activeSubDocument;
var field = subDocument.fields.create(richEdit.selection.active, 'time');
field.update(function(self) {
console.log('Result: ' + subDocument.getText(self.resultInterval));
});
hyperlinks Property
Provides access to the sub-document’s collection of hyperlinks.
Declaration
get hyperlinks(): HyperlinkCollection
Property Value
| Type | Description |
|---|---|
| HyperlinkCollection | A collection of hyperlinks. |
id Property
Gets the sub-document identifier.
Declaration
get id(): number
Property Value
| Type | Description |
|---|---|
| number | The sub-document identifier. |
images Property
Provides access to the sub-document’s images.
Declaration
get images(): Images
Property Value
| Type | Description |
|---|---|
| Images | An object that allows you to manage sub-document images. |
interval Property
Gets the text buffer interval that contains the sub-document.
Declaration
get interval(): Interval
Property Value
| Type | Description |
|---|---|
| Interval | The text buffer interval. |
Remarks
var subDocument = richEdit.selection.activeSubDocument;
subDocument.deleteText(subDocument.interval);
length Property
Gets the character length of the sub-document.
Declaration
get length(): number
Property Value
| Type | Description |
|---|---|
| number | The number of character positions in the sub-document. |
Remarks
var subDocument = richEdit.selection.activeSubDocument;
var position = subDocument.length - 1;
subDocument.insertText(position, 'text');
paragraphs Property
Provide access to sub-document paragraphs.
Declaration
get paragraphs(): ParagraphCollection
Property Value
| Type | Description |
|---|---|
| ParagraphCollection | A collection of sub-document paragraphs. |
parentSubDocument Property
Returns a sub-document where the current sub-document is placed.
Declaration
get parentSubDocument(): SubDocument | null
Property Value
| Type | Description |
|---|---|
SubDocument |
The parent sub-document. |
Remarks
Use the parentSubDocument method to get a sub-document where the current TextBox sub-document is placed. For other sub-document types (Header, Foorer, or Main), the method returns null.
rangePermissions Property
Provides access to the sub-document’s collection of range permissions.
Declaration
get rangePermissions(): RangePermissionCollection
Property Value
| Type | Description |
|---|---|
| RangePermissionCollection | A collection of range permissions. |
Remarks
Refer to the following help topic for more information: Document Protection.
tables Property
Provide access to sub-document tables.
Declaration
get tables(): TableCollection
Property Value
| Type | Description |
|---|---|
| TableCollection | A collection of sub-document tables. |
type Property
Gets the sub-document type.
Declaration
get type(): SubDocumentType
Property Value
| Type | Description |
|---|---|
| SubDocumentType | The sub-document type. |
Methods
deleteText(interval) Method
Deletes the specified text interval.
Declaration
deleteText(
interval: IInterval
): void
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | The text interval to delete. |
Remarks
var subDocument = richEdit.selection.activeSubDocument;
subDocument.deleteText(subDocument.interval);
getCharacterProperties(interval) Method
Returns character properties of the specified text interval.
Declaration
getCharacterProperties(
interval: IInterval
): CharacterProperties
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | An object that contains information about a text interval. |
Returns
| Type | Description |
|---|---|
| CharacterProperties | An object that contains the character properties. |
getHtml Method
Returns the content of the specified sub-document interval in HTML format (HTML).
Declaration
getHtml(
interval?: IInterval
): string
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | A text interval. |
Returns
| Type | Description |
|---|---|
| string | The HTML text. |
getParagraphProperties(interval) Method
Returns paragraph properties of the specified text interval.
Declaration
getParagraphProperties(
interval: IInterval
): ParagraphProperties
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | An object that contains information about a text interval. |
Returns
| Type | Description |
|---|---|
| ParagraphProperties | An object that contains the paragraph properties. |
getRtf Method
Returns the content of the specified sub-document interval in Rich Text Format (RTF).
Declaration
getRtf(
interval?: IInterval
): string
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | A text interval. |
Returns
| Type | Description |
|---|---|
| string | The RTF text. |
getText Method
Return the document’s textual representation contained in the specified interval.
Declaration
getText(
interval?: IInterval
): string
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | A document interval. |
Returns
| Type | Description |
|---|---|
| string | The text contained in the specified interval. |
Remarks
var selectedText = richEdit.selection.activeSubDocument.getText(richEdit.selection.intervals[0]);
insertColumnBreak(position) Method
Inserts the column break at the specified position in the sub-document.
Declaration
insertColumnBreak(
position: number
): Interval
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | The position in the sub-document. |
Returns
| Type | Description |
|---|---|
| Interval | The interval that contains the inserted column break. |
insertContent(position, content, documentFormat) Method
Inserts the content at the specified position.
Declaration
insertContent(
position: number,
content: string | File | Blob | ArrayBuffer,
documentFormat: DocumentFormat,
callback?: (interval: Interval,
success: boolean) => void
): void
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position in the document. |
| content | string | File | Blob | ArrayBuffer | The content to insert. |
| documentFormat | DocumentFormat | The document format of the inserted content. |
| callback | (interval: Interval, success: boolean) => void | A function that is called after the content is inserted. The interval parameter returns the inserted content’s interval. The success parameter specifies whether the content was successfully inserted. |
Remarks
The code sample below exports the document content to a file and inserts it in the current position.
richEdit.exportToFile(function(file){
richEdit.selection.activeSubDocument.insertContent(richEdit.selection.active,
file, DevExpress.RichEdit.DocumentFormat.OpenXml, function (interval, success){
if (success)
console.log('Inserted interval [' + interval.start + ', ' + interval.end + ']');
});
}, DevExpress.RichEdit.DocumentFormat.OpenXml);
insertHtml(position, htmlText) Method
Inserts the specified HTML text at the specified position.
Declaration
insertHtml(
position: number,
htmlText: string,
callback?: (interval: Interval) => void
): void
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position in the sub-document. |
| htmlText | string | The HTML text. |
| callback | (interval: Interval) => void | A function that is called after the HTML text is inserted. |
Remarks
Use the insertHtml method to insert the HTML text at the specified sub-document position. After the insertion, RichEdit calls the callback function.
If the htmlText parameter contains an entire document, the RichEdit control inserts the content of the main sub-document only.
insertLineBreak(position) Method
Inserts the line break at the specified position in the sub-document.
Declaration
insertLineBreak(
position: number
): Interval
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position in the sub-document. |
Returns
| Type | Description |
|---|---|
| Interval | The interval that contains the inserted line break. |
insertPageBreak(position) Method
Inserts the page break at the specified position in the sub-document.
Declaration
insertPageBreak(
position: number
): Interval
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | The position in the sub-document. |
Returns
| Type | Description |
|---|---|
| Interval | The interval that contains the inserted page break. |
insertParagraph(position) Method
Inserts a new paragraph into the paragraphs collection at a specified position.
Declaration
insertParagraph(
position: number
): Paragraph
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position to insert a new paragraph. |
Returns
| Type | Description |
|---|---|
| Paragraph | The newly inserted paragraph. |
insertPicture(position, base64) Method
Inserts a picture to the sub-document.
Declaration
insertPicture(
position: number,
base64: string,
size?: Size,
callback?: (interval: Interval) => void
): void
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position in the document. |
| base64 | string | The picture in string representation that is encoded with base-64 digits. |
| size | Size | The image size. |
| callback | (interval: Interval) => void | A function that is called after the picture is inserted. |
Remarks
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var image = "your-image-URL"; // base64 or url
var width = richEdit.unitConverter.pixelsToTwips(100);
var height = richEdit.unitConverter.pixelsToTwips(100);
var size = new DevExpress.RichEdit.Size(width, height);
subDocument.insertPicture(position, image, size, function(interval) { console.log("Picture loaded"); });
insertRtf(position, rtfText) Method
Inserts the specified RTF text at the specified position.
Declaration
insertRtf(
position: number,
rtfText: string,
callback?: (interval: Interval,
isRtfValid: boolean) => void
): void
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position in the document. |
| rtfText | string | The RTF text. |
| callback | (interval: Interval, isRtfValid: boolean) => void | A function that is called after the RTF text is inserted. |
Remarks
Use the insertRtf method to insert the RTF text at the specified sub-document position. After the insertion, RichEdit calls the callback function. If the inserted RTF is not valid, the isRtfValid parameter returns false.
If the rtfText parameter contains an entire document, the RichEdit control inserts the content of the main sub-document only.
insertSectionBreak(position, type) Method
Inserts the section break at the specified position in the document.
Declaration
insertSectionBreak(
position: number,
type: SectionBreakType
): Section
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position in the document. |
| type | SectionBreakType | The type of a section break. |
Returns
| Type | Description |
|---|---|
| Section | The newly created section |
insertText(position, text) Method
Inserts the specified text at the specified position.
Declaration
insertText(
position: number,
text: string
): Interval
Parameters
| Name | Type | Description |
|---|---|---|
| position | number | A position to insert the text. |
| text | string | The text to insert. |
Returns
| Type | Description |
|---|---|
| Interval | The interval that contains the inserted text. |
Remarks
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
subDocument.insertText(position, 'text');
var subDocument = richEdit.selection.activeSubDocument;
var position = subDocument.length - 1;
subDocument.insertText(position, 'text');
var createHeaderIfNotExist = true;
var section = richEdit.document.sections.getByIndex(0);
var subDocument = section.getHeader(DevExpress.RichEdit.HeaderFooterType.Primary, createHeaderIfNotExist);
var position = 0;
subDocument.insertText(position, 'text');
setCharacterProperties(interval, characterProperties) Method
Applies character properties to a text interval.
Declaration
setCharacterProperties(
interval: IInterval,
characterProperties: ICharacterProperties
): void
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | An object that contains information about a text interval. |
| characterProperties | ICharacterProperties | A CharacterProperties object that implements the ICharacterProperties interface and contains character properties. |
setParagraphProperties(interval, paragraphProperties) Method
Applies paragraph properties to a text interval.
Declaration
setParagraphProperties(
interval: IInterval,
paragraphProperties: IParagraphProperties
): void
Parameters
| Name | Type | Description |
|---|---|---|
| interval | IInterval | An object that contains information about a text interval. |
| paragraphProperties | IParagraphProperties | A ParagraphProperties object that implements the IParagraphProperties interface and contains paragraph properties. |