DocumentBuilder
Overview
DocumentBuilder is a class in Aspose.Words FOSS for Java.
Inherits from: IRunAttrSource, IParaAttrSource, IRowAttrSource, and 1 more.
Provides methods to insert text, images and other content, specify font, paragraph and section formatting.
Edition status of its 88 listed members (a property and its accessor methods are listed separately, overloads once): 1 limited, 78 not yet exercised by a verified example.
This class declares 103 methods for DocumentBuilder objects in Java programs.
Available methods include: DocumentBuilder, deleteRow, endBookmark, endColumnBookmark, endEditableRange, endRow, endTable, getBold, getCellFormat, getCurrentNode, getCurrentParagraph, getCurrentSection, and 58 additional methods.
Public members are accessible to any Java application after installing the Aspose.Words FOSS for Java package.
Properties: atEndOfParagraph, atEndOfStructuredDocumentTag, atStartOfParagraph, bold, cellFormat, currentNode, 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 | boolean | Read/Write | True if the font is formatted as bold. |
italic | boolean | Read/Write | True if the font is formatted as italic. |
underline | int | 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. |
atStartOfParagraph | boolean | Read | Returns true if the cursor is at the beginning of the current paragraph (no text before the cursor). |
atEndOfParagraph | boolean | Read | Returns true if the cursor is at the end of the current paragraph. |
atEndOfStructuredDocumentTag | boolean | 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: int) | Moves the cursor to the beginning of a header or footer in the current section. |
moveToMergeField(fieldName: String) → boolean | Moves the cursor to a position just beyond the specified merge field and removes the merge field. |
moveToMergeField(fieldName: String, isAfter: boolean, isDeleteField: boolean) → boolean | Moves the merge field to the specified merge field. |
moveToField(field: Field, isAfter: boolean) | Moves the cursor to a field in the document. |
moveToBookmark(bookmarkName: String) → boolean | Moves the cursor to a bookmark. |
moveToBookmark(bookmarkName: String, isStart: boolean, isAfter: boolean) → boolean | 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) → Row | 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() → Paragraph | Inserts a paragraph break into the document. |
insertStructuredDocumentTag(type: int) → StructuredDocumentTag | Inserts a StructuredDocumentTag into the document. |
insertStyleSeparator() | Inserts style separator into the document. |
insertBreak(breakType: int) | Inserts a break of the specified type into the document. |
insertTableOfContents(switches: String) → Field | Inserts a TOC (table of contents) field into the document. |
insertField(fieldType: int, updateField: boolean) → Field | Inserts a Word field into a document and optionally updates the field result. |
insertField(fieldCode: String) → Field | Inserts a Word field into a document and updates the field result. |
insertField(fieldCode: String, fieldValue: String) → Field | Inserts a Word field into a document without updating the field result. |
insertHyperlink(displayText: String, urlOrBookmark: String, isBookmark: boolean) → Field | Inserts a hyperlink into the document. |
insertTextInput(name: String, type: int, format: String, fieldValue: String, maxLength: int) → FormField | Inserts a text form field at the current position. |
insertCheckBox(name: String, checkedValue: boolean, size: int) → FormField | Inserts a checkbox form field at the current position. |
insertCheckBox(name: String, defaultValue: boolean, checkedValue: boolean, size: int) → FormField | Inserts a checkbox form field at the current position. |
insertComboBox(name: String, items: String[], selectedIndex: int) → FormField | Inserts a combobox form field at the current position. |
insertFootnote(footnoteType: int, footnoteText: String) → Footnote | Inserts a footnote or endnote into the document. |
insertFootnote(footnoteType: int, footnoteText: String, referenceMark: String) → Footnote | Inserts a footnote or endnote into the document. |
insertImage(image: BufferedImage) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an image from a Image object into the document. |
insertImage(fileName: String) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an image from a file or URL into the document. |
insertImage(stream: java.io.InputStream) → Shape | Limited in the FOSS edition — some inputs are rejected. Calls insertImage(stream) on this DocumentBuilder instance. |
insertImage(imageBytes: byte[]) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an image from a byte array into the document. |
insertImage(image: BufferedImage, width: double, height: double) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an inline image from a Image object into the document and scales it to the specified size. |
insertImage(fileName: String, width: double, height: double) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an inline image from a file or URL into the document and scales it to the specified size. |
insertImage(stream: java.io.InputStream, width: double, height: double) → Shape | Limited in the FOSS edition — some inputs are rejected. Calls insertImage(stream, width, height) on this DocumentBuilder instance. |
insertImage(imageBytes: byte[], width: double, height: double) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an inline image from a byte array into the document and scales it to the specified size. |
insertImage(image: BufferedImage, horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an image from a Image object at the specified position and size. |
insertImage(fileName: String, horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an image from a file or URL at the specified position and size. |
insertImage(stream: java.io.InputStream, horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | Limited in the FOSS edition — some inputs are rejected. Calls insertImage(stream, horzPos, left, vertPos, top, width, height, wrapType) on this DocumentBuilder instance. |
insertImage(imageBytes: byte[], horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | Limited in the FOSS edition — some inputs are rejected. Inserts an image from a byte array at the specified position and size. |
insertForms2OleControl(forms2OleControl: Forms2OleControl) → Shape | Inserts Forms2OleControl object into current position. |
insertHtml(html: String) | Inserts an HTML string into the document. |
insertHtml(html: String, useBuilderFormatting: boolean) | Inserts an HTML string into the document. |
insertHtml(html: String, options: int) | Inserts an HTML string into the document. |
insertGroupShape() → GroupShape | 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) → GroupShape | 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: int, width: double, height: double) → Shape | Inserts an chart object into the document and scales it to the specified size. |
insertChart(chartType: int, width: double, height: double, chartStyle: int) → Shape | Inserts an chart object into the document and scales it to the specified size. |
insertChart(chartType: int, horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | Inserts an chart object into the document and scales it to the specified size. |
insertChart(chartType: int, horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int, chartStyle: int) → Shape | Inserts an chart object into the document and scales it to the specified size. |
insertOnlineVideo(videoUrl: String, width: double, height: double) → Shape | Inserts an online video object into the document and scales it to the specified size. |
insertOnlineVideo(videoUrl: String, horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | 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) → Shape | Inserts an online video object into the document and scales it to the specified size. |
insertOnlineVideo(videoUrl: String, videoEmbedCode: String, thumbnailImageBytes: byte[], horzPos: int, left: double, vertPos: int, top: double, width: double, height: double, wrapType: int) → Shape | Inserts an online video object into the document and scales it to the specified size. |
insertHorizontalRule() → Shape | Inserts a horizontal rule shape into the document. |
insertCell() → Cell | Inserts a table cell into the document. |
startTable() → Table | Starts a table in the document. |
endTable() → Table | Ends a table in the document. |
endRow() → Row | Ends a table row in the document. |
startBookmark(bookmarkName: String) → BookmarkStart | Marks the current position in the document as a bookmark start. |
endBookmark(bookmarkName: String) → BookmarkEnd | Marks the current position in the document as a bookmark end. |
startColumnBookmark(bookmarkName: String) → BookmarkStart | Marks the current position in the document as a column bookmark start. |
endColumnBookmark(bookmarkName: String) → BookmarkEnd | Marks the current position in the document as a column bookmark end. |
startEditableRange() → EditableRangeStart | Marks the current position in the document as an editable range start. |
endEditableRange() → EditableRangeEnd | Marks the current position in the document as an editable range end. |
endEditableRange(start: EditableRangeStart) → EditableRangeEnd | Marks the current position in the document as an editable range end. |
insertDocument(srcDoc: Document, importFormatMode: int) → Node | Inserts a document at the cursor position. |
insertDocument(srcDoc: Document, importFormatMode: int, importFormatOptions: ImportFormatOptions) → Node | Inserts a document at the cursor position. |
insertDocumentInline(srcDoc: Document, importFormatMode: int, importFormatOptions: ImportFormatOptions) → Node | Inserts a document inline at the cursor position. |
getDocument() → Document | Gets or sets the Document object that this object is attached to. |
setDocument(value: Document) | Sets the document value. |
getFont() → Font | Returns an object that represents current font formatting properties. |
getBold() → boolean | True if the font is formatted as bold. |
setBold(value: boolean) | Sets the bold value. |
getItalic() → boolean | True if the font is formatted as italic. |
setItalic(value: boolean) | Sets the italic value. |
getUnderline() → int | Gets/sets underline type for the current font. |
setUnderline(value: int) | Sets the underline value. |
getParagraphFormat() → ParagraphFormat | Returns an object that represents current paragraph formatting properties. |
getListFormat() → ListFormat | Returns an object that represents current list formatting properties. |
getPageSetup() → PageSetup | Returns an object that represents current page setup and section properties. |
getRowFormat() → RowFormat | Returns an object that represents current table row formatting properties. |
getCellFormat() → CellFormat | Returns an object that represents current table cell formatting properties. |
pushFont() | Saves current character formatting onto the stack. |
popFont() | Retrieves character formatting previously saved on the stack. |
isAtStartOfParagraph() → boolean | Returns true if the cursor is at the beginning of the current paragraph (no text before the cursor). |
isAtEndOfParagraph() → boolean | Returns true if the cursor is at the end of the current paragraph. |
isAtEndOfStructuredDocumentTag() → boolean | Returns true if the cursor is at the end of a structured document tag. |
insertNode(node: Node) | Inserts a node before the cursor. |
getCurrentNode() → Node | Gets the node that is currently selected in this DocumentBuilder. |
getCurrentParagraph() → Paragraph | Gets the paragraph that is currently selected in this DocumentBuilder. |
getCurrentStructuredDocumentTag() → StructuredDocumentTag | Gets the structured document tag that is currently selected in this DocumentBuilder. |
getCurrentStory() → Story | Gets the story that is currently selected in this DocumentBuilder. |
getCurrentSection() → Section | Gets the section that is currently selected in this DocumentBuilder. |