aspnetcore-js-devexpress-dot-richedit-7faeab68.md
Defines a sub-document in a document.
export class SubDocument
SubDocument SubDocumentBase
See Also
Provide access to the sub-document’s collection of bookmarks.
get bookmarks(): BookmarkCollection<Bookmark>
| Type | Description |
|---|---|
| BookmarkCollection<Bookmark> |
A collection of bookmarks.
|
Provide access to the sub-document’s collection of fields.
get fields(): FieldCollection
| Type | Description |
|---|---|
| FieldCollection |
A collection of fields.
|
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));
});
See Also
Provides access to the sub-document’s collection of hyperlinks.
get hyperlinks(): HyperlinkCollection
| Type | Description |
|---|---|
| HyperlinkCollection |
A collection of hyperlinks.
|
Gets the sub-document identifier.
get id(): number
| Type | Description |
|---|---|
| number |
The sub-document identifier.
|
Provides access to the sub-document’s images.
get images(): Images
| Type | Description |
|---|---|
| Images |
An object that allows you to manage sub-document images.
|
See Also
How to: Create 'Change Image Size' ribbon items
Gets the text buffer interval that contains the sub-document.
get interval(): Interval
| Type | Description |
|---|---|
| Interval |
The text buffer interval.
|
var subDocument = richEdit.selection.activeSubDocument;
subDocument.deleteText(subDocument.interval);
See Also
Gets the character length of the sub-document.
get length(): number
| Type | Description |
|---|---|
| number |
The number of character positions in the sub-document.
|
var subDocument = richEdit.selection.activeSubDocument;
var position = subDocument.length - 1;
subDocument.insertText(position, 'text');
See Also
Provide access to sub-document paragraphs.
get paragraphs(): ParagraphCollection
| Type | Description |
|---|---|
| ParagraphCollection |
A collection of sub-document paragraphs.
|
Returns a sub-document where the current sub-document is placed.
get parentSubDocument(): SubDocument | null
| Type | Description |
|---|---|
SubDocument |
The parent sub-document. null if the current sub-document is a header or footer, or the main document.
|
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.
Provides access to the sub-document’s collection of range permissions.
get rangePermissions(): RangePermissionCollection
| Type | Description |
|---|---|
| RangePermissionCollection |
A collection of range permissions.
|
Refer to the following help topic for more information: Document Protection.
Provide access to sub-document tables.
get tables(): TableCollection
| Type | Description |
|---|---|
| TableCollection |
A collection of sub-document tables.
|
Gets the sub-document type.
get type(): SubDocumentType
| Type | Description |
|---|---|
| SubDocumentType |
The sub-document type.
|
Deletes the specified text interval.
deleteText(
interval: IInterval
): void
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
The text interval to delete.
|
var subDocument = richEdit.selection.activeSubDocument;
subDocument.deleteText(subDocument.interval);
See Also
Returns character properties of the specified text interval.
getCharacterProperties(
interval: IInterval
): CharacterProperties
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that contains information about a text interval.
|
| Type | Description |
|---|---|
| CharacterProperties |
An object that contains the character properties.
|
Returns the content of the specified sub-document interval in HTML format (HTML).
getHtml(
interval?: IInterval
): string
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
A text interval.
|
| Type | Description |
|---|---|
| string |
The HTML text.
|
Returns paragraph properties of the specified text interval.
getParagraphProperties(
interval: IInterval
): ParagraphProperties
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
An object that contains information about a text interval.
|
| Type | Description |
|---|---|
| ParagraphProperties |
An object that contains the paragraph properties.
|
Returns the content of the specified sub-document interval in Rich Text Format (RTF).
getRtf(
interval?: IInterval
): string
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
A text interval.
|
| Type | Description |
|---|---|
| string |
The RTF text.
|
Return the document’s textual representation contained in the specified interval.
getText(
interval?: IInterval
): string
| Name | Type | Description |
|---|---|---|
| interval | IInterval |
A document interval.
|
| Type | Description |
|---|---|
| string |
The text contained in the specified interval.
|
var selectedText = richEdit.selection.activeSubDocument.getText(richEdit.selection.intervals[0]);
See Also
Inserts the column break at the specified position in the sub-document.
insertColumnBreak(
position: number
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
The position in the sub-document.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted column break.
|
Inserts the content at the specified position.
insertContent(
position: number,
content: string | File | Blob | ArrayBuffer,
documentFormat: DocumentFormat,
callback?: (interval: Interval,
success: boolean) => void
): void
| 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.
|
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);
Inserts the specified HTML text at the specified position.
insertHtml(
position: number,
htmlText: string,
callback?: (interval: Interval) => void
): void
| 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.
|
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.
Inserts the line break at the specified position in the sub-document.
insertLineBreak(
position: number
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
A position in the sub-document.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted line break.
|
Inserts the page break at the specified position in the sub-document.
insertPageBreak(
position: number
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
The position in the sub-document.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted page break.
|
Inserts a new paragraph into the paragraphs collection at a specified position.
insertParagraph(
position: number
): Paragraph
| Name | Type | Description |
|---|---|---|
| position | number |
A position to insert a new paragraph.
|
| Type | Description |
|---|---|
| Paragraph |
The newly inserted paragraph.
|
Inserts a picture to the sub-document.
insertPicture(
position: number,
base64: string,
size?: Size,
callback?: (interval: Interval) => void
): void
| 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.
|
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"); });
See Also
Inserts the specified RTF text at the specified position.
insertRtf(
position: number,
rtfText: string,
callback?: (interval: Interval,
isRtfValid: boolean) => void
): void
| 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.
|
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.
Inserts the section break at the specified position in the document.
insertSectionBreak(
position: number,
type: SectionBreakType
): Section
| Name | Type | Description |
|---|---|---|
| position | number |
A position in the document.
| | type | SectionBreakType |
The type of a section break.
|
| Type | Description |
|---|---|
| Section |
The newly created section
|
Inserts the specified text at the specified position.
insertText(
position: number,
text: string
): Interval
| Name | Type | Description |
|---|---|---|
| position | number |
A position to insert the text.
| | text | string |
The text to insert.
|
| Type | Description |
|---|---|
| Interval |
The interval that contains the inserted text.
|
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');
See Also
Applies character properties to a text interval.
setCharacterProperties(
interval: IInterval,
characterProperties: ICharacterProperties
): void
| 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.
|
Applies paragraph properties to a text interval.
setParagraphProperties(
interval: IInterval,
paragraphProperties: IParagraphProperties
): void
| 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.
|