DocumentBuilder

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

NameTypeAccessDescription
documentDocumentRead/WriteGets or sets the Document object that this object is attached to.
fontFontReadReturns an object that represents current font formatting properties.
boldbooleanRead/WriteTrue if the font is formatted as bold.
italicbooleanRead/WriteTrue if the font is formatted as italic.
underlineintRead/WriteGets/sets underline type for the current font.
paragraphFormatParagraphFormatReadReturns an object that represents current paragraph formatting properties.
listFormatListFormatReadReturns an object that represents current list formatting properties.
pageSetupPageSetupReadReturns an object that represents current page setup and section properties.
rowFormatRowFormatReadReturns an object that represents current table row formatting properties.
cellFormatCellFormatReadReturns an object that represents current table cell formatting properties.
atStartOfParagraphbooleanReadReturns true if the cursor is at the beginning of the current paragraph (no text before the cursor).
atEndOfParagraphbooleanReadReturns true if the cursor is at the end of the current paragraph.
atEndOfStructuredDocumentTagbooleanReadReturns true if the cursor is at the end of a structured document tag.
currentNodeNodeReadGets the node that is currently selected in this DocumentBuilder.
currentParagraphParagraphReadGets the paragraph that is currently selected in this DocumentBuilder.
currentStructuredDocumentTagStructuredDocumentTagReadGets the structured document tag that is currently selected in this DocumentBuilder.
currentStoryStoryReadGets the story that is currently selected in this DocumentBuilder.
currentSectionSectionReadGets the section that is currently selected in this DocumentBuilder.

Methods

SignatureDescription
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) → booleanMoves the cursor to a position just beyond the specified merge field and removes the merge field.
moveToMergeField(fieldName: String, isAfter: boolean, isDeleteField: boolean) → booleanMoves 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) → booleanMoves the cursor to a bookmark.
moveToBookmark(bookmarkName: String, isStart: boolean, isAfter: boolean) → booleanMoves 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) → RowDeletes 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() → ParagraphInserts a paragraph break into the document.
insertStructuredDocumentTag(type: int) → StructuredDocumentTagInserts 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) → FieldInserts a TOC (table of contents) field into the document.
insertField(fieldType: int, updateField: boolean) → FieldInserts a Word field into a document and optionally updates the field result.
insertField(fieldCode: String) → FieldInserts a Word field into a document and updates the field result.
insertField(fieldCode: String, fieldValue: String) → FieldInserts a Word field into a document without updating the field result.
insertHyperlink(displayText: String, urlOrBookmark: String, isBookmark: boolean) → FieldInserts a hyperlink into the document.
insertTextInput(name: String, type: int, format: String, fieldValue: String, maxLength: int) → FormFieldInserts a text form field at the current position.
insertCheckBox(name: String, checkedValue: boolean, size: int) → FormFieldInserts a checkbox form field at the current position.
insertCheckBox(name: String, defaultValue: boolean, checkedValue: boolean, size: int) → FormFieldInserts a checkbox form field at the current position.
insertComboBox(name: String, items: String[], selectedIndex: int) → FormFieldInserts a combobox form field at the current position.
insertFootnote(footnoteType: int, footnoteText: String) → FootnoteInserts a footnote or endnote into the document.
insertFootnote(footnoteType: int, footnoteText: String, referenceMark: String) → FootnoteInserts a footnote or endnote into the document.
insertImage(image: BufferedImage) → ShapeLimited in the FOSS edition — some inputs are rejected. Inserts an image from a Image object into the document.
insertImage(fileName: String) → ShapeLimited in the FOSS edition — some inputs are rejected. Inserts an image from a file or URL into the document.
insertImage(stream: java.io.InputStream) → ShapeLimited in the FOSS edition — some inputs are rejected. Calls insertImage(stream) on this DocumentBuilder instance.
insertImage(imageBytes: byte[]) → ShapeLimited 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) → ShapeLimited 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) → ShapeLimited 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) → ShapeLimited in the FOSS edition — some inputs are rejected. Calls insertImage(stream, width, height) on this DocumentBuilder instance.
insertImage(imageBytes: byte[], width: double, height: double) → ShapeLimited 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) → ShapeLimited 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) → ShapeLimited 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) → ShapeLimited 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) → ShapeLimited in the FOSS edition — some inputs are rejected. Inserts an image from a byte array at the specified position and size.
insertForms2OleControl(forms2OleControl: Forms2OleControl) → ShapeInserts 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() → GroupShapeGroups 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) → GroupShapeGroups 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) → ShapeInserts an chart object into the document and scales it to the specified size.
insertChart(chartType: int, width: double, height: double, chartStyle: int) → ShapeInserts 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) → ShapeInserts 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) → ShapeInserts an chart object into the document and scales it to the specified size.
insertOnlineVideo(videoUrl: String, width: double, height: double) → ShapeInserts 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) → ShapeInserts 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) → ShapeInserts 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) → ShapeInserts an online video object into the document and scales it to the specified size.
insertHorizontalRule() → ShapeInserts a horizontal rule shape into the document.
insertCell() → CellInserts a table cell into the document.
startTable() → TableStarts a table in the document.
endTable() → TableEnds a table in the document.
endRow() → RowEnds a table row in the document.
startBookmark(bookmarkName: String) → BookmarkStartMarks the current position in the document as a bookmark start.
endBookmark(bookmarkName: String) → BookmarkEndMarks the current position in the document as a bookmark end.
startColumnBookmark(bookmarkName: String) → BookmarkStartMarks the current position in the document as a column bookmark start.
endColumnBookmark(bookmarkName: String) → BookmarkEndMarks the current position in the document as a column bookmark end.
startEditableRange() → EditableRangeStartMarks the current position in the document as an editable range start.
endEditableRange() → EditableRangeEndMarks the current position in the document as an editable range end.
endEditableRange(start: EditableRangeStart) → EditableRangeEndMarks the current position in the document as an editable range end.
insertDocument(srcDoc: Document, importFormatMode: int) → NodeInserts a document at the cursor position.
insertDocument(srcDoc: Document, importFormatMode: int, importFormatOptions: ImportFormatOptions) → NodeInserts a document at the cursor position.
insertDocumentInline(srcDoc: Document, importFormatMode: int, importFormatOptions: ImportFormatOptions) → NodeInserts a document inline at the cursor position.
getDocument() → DocumentGets or sets the Document object that this object is attached to.
setDocument(value: Document)Sets the document value.
getFont() → FontReturns an object that represents current font formatting properties.
getBold() → booleanTrue if the font is formatted as bold.
setBold(value: boolean)Sets the bold value.
getItalic() → booleanTrue if the font is formatted as italic.
setItalic(value: boolean)Sets the italic value.
getUnderline() → intGets/sets underline type for the current font.
setUnderline(value: int)Sets the underline value.
getParagraphFormat() → ParagraphFormatReturns an object that represents current paragraph formatting properties.
getListFormat() → ListFormatReturns an object that represents current list formatting properties.
getPageSetup() → PageSetupReturns an object that represents current page setup and section properties.
getRowFormat() → RowFormatReturns an object that represents current table row formatting properties.
getCellFormat() → CellFormatReturns 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() → booleanReturns true if the cursor is at the beginning of the current paragraph (no text before the cursor).
isAtEndOfParagraph() → booleanReturns true if the cursor is at the end of the current paragraph.
isAtEndOfStructuredDocumentTag() → booleanReturns true if the cursor is at the end of a structured document tag.
insertNode(node: Node)Inserts a node before the cursor.
getCurrentNode() → NodeGets the node that is currently selected in this DocumentBuilder.
getCurrentParagraph() → ParagraphGets the paragraph that is currently selected in this DocumentBuilder.
getCurrentStructuredDocumentTag() → StructuredDocumentTagGets the structured document tag that is currently selected in this DocumentBuilder.
getCurrentStory() → StoryGets the story that is currently selected in this DocumentBuilder.
getCurrentSection() → SectionGets the section that is currently selected in this DocumentBuilder.

See Also