DocumentBuilder
Overview
DocumentBuilder is a class in Aspose.Words FOSS for .NET.
Inherits from: IRunAttrSource, IParaAttrSource, IRowAttrSource, and 1 more.
Provides methods to insert text, images and other content, specify font, paragraph and section formatting.
This class provides 81 methods for working with DocumentBuilder objects in .NET programs.
Available methods include: DeleteRow, DocumentBuilder, EndBookmark, EndColumnBookmark, EndEditableRange, EndRow, EndTable, InsertBreak, InsertCell, InsertChart, InsertCheckBox, InsertComboBox, and 36 additional methods.
All public members are accessible to any .NET application after installing the Aspose.Words FOSS for .NET package.
Properties: Bold, CellFormat, CurrentNode, CurrentParagraph, CurrentSection, CurrentStory, and 12 more.
Properties
| Name | Type | Access | Description |
|---|---|---|---|
Document | Document | Read/Write | Gets or sets the Document object that this object is attached to. |
Font | Font | Read | Returns an object that represents current font formatting properties. |
Bold | bool | Read/Write | True if the font is formatted as bold. |
Italic | bool | Read/Write | True if the font is formatted as italic. |
Underline | Underline | Read/Write | Gets/sets underline type for the current font. |
ParagraphFormat | ParagraphFormat | Read | Returns an object that represents current paragraph formatting properties. |
ListFormat | ListFormat | Read | Returns an object that represents current list formatting properties. |
PageSetup | PageSetup | Read | Returns an object that represents current page setup and section properties. |
RowFormat | RowFormat | Read | Returns an object that represents current table row formatting properties. |
CellFormat | CellFormat | Read | Returns an object that represents current table cell formatting properties. |
IsAtStartOfParagraph | bool | Read | Returns true if the cursor is at the beginning of the current paragraph (no text before the cursor). |
IsAtEndOfParagraph | bool | Read | Returns true if the cursor is at the end of the current paragraph. |
IsAtEndOfStructuredDocumentTag | bool | Read | Returns true if the cursor is at the end of a structured document tag. |
CurrentNode | Node | Read | Gets the node that is currently selected in this DocumentBuilder. |
CurrentParagraph | Paragraph | Read | Gets the paragraph that is currently selected in this DocumentBuilder. |
CurrentStructuredDocumentTag | StructuredDocumentTag | Read | Gets the structured document tag that is currently selected in this DocumentBuilder. |
CurrentStory | Story | Read | Gets the story that is currently selected in this DocumentBuilder. |
CurrentSection | Section | Read | Gets the section that is currently selected in this DocumentBuilder. |
Methods
| Signature | Description |
|---|---|
DocumentBuilder() | Initializes a new instance of this class. |
DocumentBuilder(options: DocumentBuilderOptions) | Initializes a new instance of this class. |
DocumentBuilder(doc: Document) | Initializes a new instance of this class. |
DocumentBuilder(doc: Document, options: DocumentBuilderOptions) | Initializes a new instance of this class. |
MoveToDocumentStart() | Moves the cursor to the beginning of the document. |
MoveToDocumentEnd() | Moves the cursor to the end of the document. |
MoveToSection(sectionIndex: int) | Moves the cursor to the beginning of the body in a specified section. |
MoveToHeaderFooter(headerFooterType: HeaderFooterType) | Moves the cursor to the beginning of a header or footer in the current section. |
MoveToMergeField(fieldName: string) | Moves the cursor to the specified merge field. |
MoveToMergeField(fieldName: string, isAfter: bool, isDeleteField: bool) | Moves the merge field to the specified merge field. |
MoveToField(field: Field, isAfter: bool) | Moves the cursor to a field in the document. |
MoveToBookmark(bookmarkName: string) | Moves the cursor to a bookmark. |
MoveToBookmark(bookmarkName: string, isStart: bool, isAfter: bool) | Moves the cursor to a bookmark with greater precision. |
MoveToParagraph(paragraphIndex: int, characterIndex: int) | Moves the cursor to a paragraph in the current section. |
MoveToStructuredDocumentTag(structuredDocumentTagIndex: int, characterIndex: int) | Moves the cursor to a structured document tag in the current section. |
MoveToStructuredDocumentTag(structuredDocumentTag: StructuredDocumentTag, characterIndex: int) | Moves the cursor to the structured document tag. |
MoveToCell(tableIndex: int, rowIndex: int, columnIndex: int, characterIndex: int) | Moves the cursor to a table cell in the current section. |
MoveTo(node: Node) | Moves the cursor to an inline node or to the end of a paragraph. |
DeleteRow(tableIndex: int, rowIndex: int) | Deletes a row from a table. |
Write(text: string) | Inserts a string into the document at the current insert position. |
Writeln(text: string) | Inserts a string and a paragraph break into the document. |
Writeln() | Inserts a paragraph break into the document. |
InsertParagraph() | Inserts a paragraph break into the document. |
InsertStructuredDocumentTag(type: SdtType) | Inserts a StructuredDocumentTag into the document. |
InsertStyleSeparator() | Inserts style separator into the document. |
InsertBreak(breakType: BreakType) | Inserts a break of the specified type into the document. |
InsertTableOfContents(switches: string) | Inserts a TOC (table of contents) field into the document. |
InsertField(fieldType: FieldType, updateField: bool) | Inserts a Word field into a document. |
InsertField(fieldCode: string) | Inserts a Word field into a document and updates the field result. |
InsertField(fieldCode: string, fieldValue: string) | Inserts a Word field into a document without updating the field result. |
InsertHyperlink(displayText: string, urlOrBookmark: string, isBookmark: bool) | Inserts a hyperlink into the document. |
InsertTextInput(name: string, type: TextFormFieldType, format: string, fieldValue: string, maxLength: int) | Inserts a text form field at the current position. |
InsertCheckBox(name: string, checkedValue: bool, size: int) | Inserts a checkbox form field at the current position. |
InsertCheckBox(name: string, defaultValue: bool, checkedValue: bool, size: int) | Inserts a checkbox form field at the current position. |
InsertComboBox(name: string, items: string[], selectedIndex: int) | Inserts a combobox form field at the current position. |
InsertFootnote(footnoteType: FootnoteType, footnoteText: string) | Inserts a footnote or endnote into the document. |
InsertFootnote(footnoteType: FootnoteType, footnoteText: string, referenceMark: string) | Inserts a footnote or endnote into the document. |
InsertImage(image: Image) | Inserts an image into the document. |
InsertImage(fileName: string) | Inserts an image from a file or URL into the document. |
InsertImage(stream: Stream) | Calls InsertImage(stream) on this DocumentBuilder instance. |
InsertImage(imageBytes: byte[]) | Inserts an image from a byte array into the document. |
InsertImage(image: Image, width: double, height: double) | Inserts an inline image from a .NET ImageImageImage object into the document and scales it to the specified size. |
InsertImage(fileName: string, width: double, height: double) | Inserts an inline image from a file or URL into the document and scales it to the specified size. |
InsertImage(stream: Stream, width: double, height: double) | Calls InsertImage(stream, width, height) on this DocumentBuilder instance. |
InsertImage(imageBytes: byte[], width: double, height: double) | Inserts an inline image from a byte array into the document and scales it to the specified size. |
InsertImage(image: Image, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Inserts an image from a .NET ImageImageImage object at the specified position and size. |
InsertImage(fileName: string, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Inserts an image from a file or URL at the specified position and size. |
InsertImage(stream: Stream, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Calls InsertImage(stream, horzPos, left, vertPos, top, width, height, wrapType) on this DocumentBuilder instance. |
InsertImage(imageBytes: byte[], horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Inserts an image from a byte array at the specified position and size. |
InsertForms2OleControl(forms2OleControl: Forms2OleControl) | Inserts Forms2OleControl object into current position. |
InsertHtml(html: string) | Inserts an HTML string into the document. |
InsertHtml(html: string, useBuilderFormatting: bool) | Inserts an HTML string into the document. |
InsertHtml(html: string, options: HtmlInsertOptions) | Inserts an HTML string into the document. |
InsertGroupShape(shapes) | Groups the shapes passed as a parameter into a new GroupShape node which is inserted into the current position. |
InsertGroupShape(left: double, top: double, width: double, height: double, shapes) | Groups the shapes passed as a parameter into a new GroupShape node of the specified size which is inserted into the specified position. |
InsertChart(chartType: ChartType, width: double, height: double) | Inserts an chart object into the document and scales it to the specified size. |
InsertChart(chartType: ChartType, width: double, height: double, chartStyle: ChartStyle) | Inserts an chart object into the document and scales it to the specified size. |
InsertChart(chartType: ChartType, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Inserts an chart object into the document and scales it to the specified size. |
InsertChart(chartType: ChartType, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType, chartStyle: ChartStyle) | Inserts an chart object into the document and scales it to the specified size. |
InsertOnlineVideo(videoUrl: string, width: double, height: double) | Inserts an online video object into the document and scales it to the specified size. |
InsertOnlineVideo(videoUrl: string, horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Inserts an online video object into the document and scales it to the specified size. |
InsertOnlineVideo(videoUrl: string, videoEmbedCode: string, thumbnailImageBytes: byte[], width: double, height: double) | Inserts an online video object into the document and scales it to the specified size. |
InsertOnlineVideo(videoUrl: string, videoEmbedCode: string, thumbnailImageBytes: byte[], horzPos: RelativeHorizontalPosition, left: double, vertPos: RelativeVerticalPosition, top: double, width: double, height: double, wrapType: WrapType) | Inserts an online video object into the document and scales it to the specified size. |
InsertHorizontalRule() | Inserts a horizontal rule shape into the document. |
InsertCell() | Inserts a table cell into the document. |
StartTable() | Starts a table in the document. |
EndTable() | Ends a table in the document. |
EndRow() | Ends a table row in the document. |
StartBookmark(bookmarkName: string) | Marks the current position in the document as a bookmark start. |
EndBookmark(bookmarkName: string) | Marks the current position in the document as a bookmark end. |
StartColumnBookmark(bookmarkName: string) | Marks the current position in the document as a column bookmark start. |
EndColumnBookmark(bookmarkName: string) | Marks the current position in the document as a column bookmark end. |
StartEditableRange() | Marks the current position in the document as an editable range start. |
EndEditableRange() | Marks the current position in the document as an editable range end. |
EndEditableRange(start: EditableRangeStart) | Marks the current position in the document as an editable range end. |
InsertDocument(srcDoc: Document, importFormatMode: ImportFormatMode) | Inserts a document at the cursor position. |
InsertDocument(srcDoc: Document, importFormatMode: ImportFormatMode, importFormatOptions: ImportFormatOptions) | Inserts a document at the cursor position. |
InsertDocumentInline(srcDoc: Document, importFormatMode: ImportFormatMode, importFormatOptions: ImportFormatOptions) | Inserts a document inline at the cursor position. |
PushFont() | Saves current character formatting onto the stack. |
PopFont() | Retrieves character formatting previously saved on the stack. |
InsertNode(node: Node) | Inserts a node before the cursor. |