Skip to main content
A newer version of this page is available. .

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

readonly bookmarks: BookmarkCollection<Bookmark>

Property Value

Type Description
BookmarkCollection<Bookmark>

A collection of bookmarks.

id Property

Gets the sub-document identifier.

Declaration

readonly id: number

Property Value

Type Description
number

The sub-document identifier.

interval Property

Gets the text buffer interval that contains the sub-document.

Declaration

readonly interval: Interval

Property Value

Type Description
Interval

The text buffer interval.

Remarks

//Deletes all text in the active sub-document
richEdit.selection.activeSubDocument.deleteText(richEdit.selection.activeSubDocument.interval);
See Also

length Property

Gets the character length of the sub-document.

Declaration

readonly length: number

Property Value

Type Description
number

The number of character positions in the sub-document.

Remarks

//Inserts a text at the end of the active sub-document
richEdit.selection.activeSubDocument.insertText(richEdit.selection.activeSubDocument.length - 1, 'sometext');
See Also

paragraphs Property

Provide access to sub-document paragraphs.

Declaration

readonly 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

readonly parentSubDocument: SubDocument | null

Property Value

Type Description
SubDocument

The parent sub-document.

null

The current sub-document is a header, or footer, or the main 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.

tables Property

Provide access to sub-document tables.

Declaration

readonly tables: TableCollection

Property Value

Type Description
TableCollection

A collection of sub-document tables.

type Property

Gets the sub-document type.

Declaration

readonly 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

richEdit.document.subDocuments.main.deleteText({start: 10, length: 15});
See Also

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.

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.

getText Method

Return the document’s textual representation contained in the specified interval.

Declaration

getText(
    interval?: Interval
): string

Parameters

Name Type Description
interval Interval

A document interval.

Returns

Type Description
string

The text contained in the specified interval.

Remarks

//Gets the selected text
var selectedText = richEdit.selection.activeSubDocument.getText(richEdit.selection.intervals[0]);
See Also

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.

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

//Inserts a picture at a certain position
richEdit.selection.activeSubDocument.insertPicture(position, image);
See Also

insertSectionBreak(position, type) Method

Inserts the section break at the specified position in the document.

Declaration

insertSectionBreak(
    position: number,
    type: SectionBreakType
): void

Parameters

Name Type Description
position number

A position in the document.

type SectionBreakType

The type of a section break.

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

//Inserts a text at the cursor position
richEdit.selection.activeSubDocument.insertText(richEdit.selection.active,'sometext');
See Also

setCharacterProperties(interval, characterProperties) Method

Applies character properties to a text interval.

Declaration

setCharacterProperties(
    interval: IInterval,
    characterProperties: CharacterProperties
): void

Parameters

Name Type Description
interval IInterval

An object that contains information about a text interval.

characterProperties CharacterProperties

An object that contains the applied character properties.

setParagraphProperties(interval, paragraphProperties) Method

Applies paragraph properties to a text interval.

Declaration

setParagraphProperties(
    interval: IInterval,
    paragraphProperties: ParagraphProperties
): void

Parameters

Name Type Description
interval IInterval

An object that contains information about a text interval.

paragraphProperties ParagraphProperties

An object that contains the applied paragraph properties.