java.lang.Objectcom.aspose.words.DocumentBuilder
public class DocumentBuilder
DocumentBuilder makes the process of building a Document easier.
Document is a composite object consisting of a tree of nodes and while inserting content
nodes directly into the tree is possible, it requires good understanding of the tree structure.
DocumentBuilder is a "facade" for the complex structure of Document and allows
to insert content and formatting quickly and easily. Create a DocumentBuilder and associate it with a The DocumentBuilder has an internal cursor where the text will be inserted
when you call Use the Use the Use the Use the Note that Font, ParagraphFormat and PageSetup properties are updated whenever
you navigate to a different place in the document to reflect formatting properties available at the new location.
Constructor Summary |
---|
DocumentBuilder()
Initializes a new instance of this class. |
DocumentBuilder(Document doc)
Initializes a new instance of this class. |
Property Getters/Setters Summary | ||
---|---|---|
boolean | getBold() | |
void | setBold(boolean value) | |
True if the font is formatted as bold. | ||
Aspose.Words.Tables.CellFormat | getCellFormat() | |
Returns an object that represents current table cell formatting properties. | ||
Node | getCurrentNode() | |
Gets the node that is currently selected in this DocumentBuilder. | ||
Paragraph | getCurrentParagraph() | |
Gets the paragraph that is currently selected in this DocumentBuilder. | ||
Section | getCurrentSection() | |
Gets the section that is currently selected in this DocumentBuilder. | ||
Story | getCurrentStory() | |
Gets the story that is currently selected in this DocumentBuilder. | ||
Document | getDocument() | |
void | setDocument(Document value) | |
Gets or sets the |
||
Font | getFont() | |
Returns an object that represents current font formatting properties. | ||
boolean | isAtEndOfParagraph() | |
Returns true if the cursor is at the end of the current paragraph. | ||
boolean | isAtStartOfParagraph() | |
Returns true if the cursor is at the beginning of the current paragraph (no text before the cursor). | ||
boolean | getItalic() | |
void | setItalic(boolean value) | |
True if the font is formatted as italic. | ||
ListFormat | getListFormat() | |
Returns an object that represents current list formatting properties. | ||
PageSetup | getPageSetup() | |
Returns an object that represents current page setup and section properties. | ||
ParagraphFormat | getParagraphFormat() | |
Returns an object that represents current paragraph formatting properties. | ||
Aspose.Words.Tables.RowFormat | getRowFormat() | |
Returns an object that represents current table row formatting properties. | ||
int | getUnderline() | |
void | setUnderline(int value) | |
Gets/sets underline type for the current font. The value of the property is Underline integer constant. |
Method Summary | ||
---|---|---|
void | clearCellAttrs() | |
Reserved for internal use. | ||
void | clearRowAttrs() | |
Reserved for internal use. | ||
void | clearRunAttrs() | |
Reserved for internal use. | ||
Aspose.Words.Tables.Row | deleteRow(int tableIndex, int rowIndex) | |
Deletes a row from a table. | ||
BookmarkEnd | endBookmark(java.lang.String bookmarkName) | |
Marks the current position in the document as a bookmark end. | ||
EditableRangeEnd | endEditableRange() | |
Marks the current position in the document as an editable range end. | ||
EditableRangeEnd | endEditableRange(EditableRangeStart start) | |
Marks the current position in the document as an editable range end. | ||
Aspose.Words.Tables.Row | endRow() | |
Ends a table row in the document. | ||
Aspose.Words.Tables.Table | endTable() | |
Ends a table in the document. | ||
java.lang.Object | fetchCellAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | fetchInheritedCellAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | fetchInheritedRowAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | fetchInheritedRunAttr(int fontAttr) | |
Reserved for internal use. | ||
java.lang.Object | fetchRowAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | getDirectCellAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | getDirectRowAttr(int key) | |
Reserved for internal use. | ||
java.lang.Object | getDirectRunAttr(int fontAttr) | |
Reserved for internal use. | ||
int | getDirectRunAttrsCount() | |
Reserved for internal use. | ||
void | insertBreak(int breakType) | |
Inserts a break of the specified type into the document. | ||
Aspose.Words.Tables.Cell | insertCell() | |
Inserts a table cell into the document. | ||
Aspose.Words.Fields.FormField | insertCheckBox(java.lang.String name, boolean defaultValue, boolean checkedValue, int size) | |
Inserts a checkbox form field at the current position. | ||
Aspose.Words.Fields.FormField | insertCheckBox(java.lang.String name, boolean checkedValue, int size) | |
Inserts a checkbox form field at the current position. | ||
Aspose.Words.Fields.FormField | insertComboBox(java.lang.String name, java.lang.String[] items, int selectedIndex) | |
Inserts a combobox form field at the current position. | ||
Node | insertDocument(Document srcDoc, int importFormatMode) | |
Inserts content of the document into the current position of DocumentBuilder's cursor. | ||
Aspose.Words.Fields.Field | insertField(java.lang.String fieldCode) | |
Inserts a Word field into a document and updates the field result. | ||
Aspose.Words.Fields.Field | insertField(java.lang.String fieldCode, java.lang.String fieldValue) | |
Inserts a Word field into a document without updating the field result. | ||
Footnote | insertFootnote(int footnoteType, java.lang.String footnoteText) | |
Inserts a footnote or endnote into the document. | ||
Footnote | insertFootnote(int footnoteType, java.lang.String footnoteText, java.lang.String referenceMark) | |
Inserts a footnote or endnote into the document. | ||
void | insertHtml(java.lang.String html) | |
Inserts an HTML string into the document. | ||
void | insertHtml(java.lang.String html, boolean useBuilderFormatting) | |
Inserts an HTML string into the document. | ||
Aspose.Words.Fields.Field | insertHyperlink(java.lang.String displayText, java.lang.String urlOrBookmark, boolean isBookmark) | |
Inserts a hyperlink into the document. | ||
Shape | insertImage(byte[] imageBytes) | |
Inserts an image from a byte array into the document. The image is inserted inline and at 100% scale. | ||
Shape | insertImage(byte[] imageBytes, double width, double height) | |
Inserts an inline image from a byte array into the document and scales it to the specified size. | ||
Shape | insertImage(byte[] imageBytes, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a byte array at the specified position and size. | ||
Shape | insertImage(java.io.InputStream stream) | |
Inserts an image from a stream into the document. The image is inserted inline and at 100% scale. | ||
Shape | insertImage(java.io.InputStream stream, double width, double height) | |
Inserts an inline image from a stream into the document and scales it to the specified size. | ||
Shape | insertImage(java.io.InputStream stream, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a stream at the specified position and size. | ||
Shape | insertImage(java.lang.String fileName) | |
Inserts an image from a file or URL into the document. The image is inserted inline and at 100% scale. | ||
Shape | insertImage(java.lang.String fileName, double width, double height) | |
Inserts an inline image from a file or URL into the document and scales it to the specified size. | ||
Shape | insertImage(java.lang.String fileName, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an image from a file or URL at the specified position and size. | ||
void | insertNode(Node node) | |
Inserts a text level node inside the current paragraph before the cursor. | ||
Shape | insertOnlineVideo(java.lang.String videoUrl, double width, double height) | |
Inserts an online video object into the document and scales it to the specified size. | ||
Shape | insertOnlineVideo(java.lang.String videoUrl, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an online video object into the document and scales it to the specified size. | ||
Shape | insertOnlineVideo(java.lang.String videoUrl, java.lang.String videoEmbedCode, byte[] thumbnailImageBytes, double width, double height) | |
Inserts an online video object into the document and scales it to the specified size. | ||
Shape | insertOnlineVideo(java.lang.String videoUrl, java.lang.String videoEmbedCode, byte[] thumbnailImageBytes, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) | |
Inserts an online video object into the document and scales it to the specified size. | ||
Paragraph | insertParagraph() | |
Inserts a paragraph break into the document. | ||
Shape | insertSignatureLine(SignatureLineOptions signatureLineOptions) | |
Inserts a signature line at the current position. | ||
Shape | insertSignatureLine(SignatureLineOptions signatureLineOptions, int horzPos, double left, int vertPos, double top, int wrapType) | |
Inserts a signature line at the specified position. | ||
Aspose.Words.Fields.Field | insertTableOfContents(java.lang.String switches) | |
Inserts a TOC (table of contents) field into the document. | ||
void | moveTo(Node node) | |
Moves the cursor to an inline node or to the end of a paragraph. | ||
boolean | moveToBookmark(java.lang.String bookmarkName) | |
Moves the cursor to a bookmark. | ||
boolean | moveToBookmark(java.lang.String bookmarkName, boolean isStart, boolean isAfter) | |
Moves the cursor to a bookmark with greater precision. | ||
void | moveToCell(int tableIndex, int rowIndex, int columnIndex, int characterIndex) | |
Moves the cursor to a table cell in the current section. | ||
void | moveToDocumentEnd() | |
Moves the cursor to the end of the document. | ||
void | moveToDocumentStart() | |
Moves the cursor to the beginning of the document. | ||
void | moveToHeaderFooter(int headerFooterType) | |
Moves the cursor to the beginning of a header or footer in the current section. | ||
boolean | moveToMergeField(java.lang.String fieldName) | |
Moves the cursor to a position just beyond the specified merge field and removes the merge field. | ||
boolean | moveToMergeField(java.lang.String fieldName, boolean isAfter, boolean isDeleteField) | |
Moves the merge field to the specified merge field. | ||
void | moveToParagraph(int paragraphIndex, int characterIndex) | |
Moves the cursor to a paragraph in the current section. | ||
void | moveToSection(int sectionIndex) | |
Moves the cursor to the beginning of the body in a specified section. | ||
void | popFont() | |
Retrieves character formatting previously saved on the stack. | ||
void | pushFont() | |
Saves current character formatting onto the stack. | ||
void | removeRunAttr(int key) | |
Reserved for internal use. | ||
void | resetToDefaultAttrs() | |
Reserved for internal use. | ||
void | setCellAttr(int key, java.lang.Object value) | |
Reserved for internal use. | ||
void | setRowAttr(int key, java.lang.Object value) | |
Reserved for internal use. | ||
void | setRunAttr(int fontAttr, java.lang.Object value) | |
Reserved for internal use. | ||
BookmarkStart | startBookmark(java.lang.String bookmarkName) | |
Marks the current position in the document as a bookmark start. | ||
EditableRangeStart | startEditableRange() | |
Marks the current position in the document as an editable range start. | ||
Aspose.Words.Tables.Table | startTable() | |
Starts a table in the document. | ||
void | write(java.lang.String text) | |
Inserts a string into the document at the current insert position. | ||
void | writeln() | |
Inserts a paragraph break into the document. | ||
void | writeln(java.lang.String text) | |
Inserts a string and a paragraph break into the document. |
Constructor Detail |
---|
public DocumentBuilder() throws java.lang.Exception
public DocumentBuilder(Document doc)
doc
- The Document object to attach to.Property Getters/Setters Detail |
---|
getBold/setBold | |
public boolean getBold() / public void setBold(boolean value) |
getCellFormat | |
public Aspose.Words.Tables.CellFormat getCellFormat() |
getCurrentNode | |
public Node getCurrentNode() |
CurrentNode is a cursor of DocumentBuilder and points to a Node that is a direct child of a Paragraph. Any insert operations you perform using DocumentBuilder will insert before the CurrentNode.
When the current paragraph is empty or the cursor is positioned just before the end of the paragraph, CurrentNode returns null.
getCurrentParagraph | |
public Paragraph getCurrentParagraph() |
getCurrentSection | |
public Section getCurrentSection() |
getCurrentStory | |
public Story getCurrentStory() |
getDocument/setDocument | |
public Document getDocument() / public void setDocument(Document value) |
getFont | |
public Font getFont() |
Use Font to access and modify font formatting properties.
Specify font formatting before inserting text.
isAtEndOfParagraph | |
public boolean isAtEndOfParagraph() |
isAtStartOfParagraph | |
public boolean isAtStartOfParagraph() |
getItalic/setItalic | |
public boolean getItalic() / public void setItalic(boolean value) |
getListFormat | |
public ListFormat getListFormat() |
getPageSetup | |
public PageSetup getPageSetup() |
getParagraphFormat | |
public ParagraphFormat getParagraphFormat() |
getRowFormat | |
public Aspose.Words.Tables.RowFormat getRowFormat() |
getUnderline/setUnderline | |
public int getUnderline() / public void setUnderline(int value) |
Method Detail |
---|
clearCellAttrs | |
public void clearCellAttrs() |
clearRowAttrs | |
public void clearRowAttrs() |
clearRunAttrs | |
public void clearRunAttrs() |
deleteRow | |
public Aspose.Words.Tables.Row deleteRow(int tableIndex, int rowIndex) |
If the cursor is inside the row that is being deleted, the cursor is moved out to the next row or to the next paragraph after the table.
If you delete a row from a table that contains only one row, the whole table is deleted.
For the index parameters, when index is greater than or equal to 0, it specifies an index from the beginning with 0 being the first element. When index is less than 0, it specified an index from the end with -1 being the last element.
tableIndex
- The index of the table.rowIndex
- The index of the row in the table.endBookmark | |
public BookmarkEnd endBookmark(java.lang.String bookmarkName) |
Bookmarks in a document can overlap and span any range. To create a valid bookmark you need to
call both
Badly formed bookmarks or bookmarks with duplicate names will be ignored when the document is saved.
bookmarkName
- Name of the bookmark.endEditableRange | |
public EditableRangeEnd endEditableRange() |
Editable range in a document can overlap and span any range. To create a valid editable range you need to
call both
Badly formed editable range will be ignored when the document is saved.
endEditableRange | |
public EditableRangeEnd endEditableRange(EditableRangeStart start) |
Use this overload during creating nested editable ranges.
Editable range in a document can overlap and span any range. To create a valid editable range you need to
call both
Badly formed editable range will be ignored when the document is saved.
start
- This editable range start.endRow | |
public Aspose.Words.Tables.Row endRow() |
Call EndRow to end a table row. If you call
Use the
endTable | |
public Aspose.Words.Tables.Table endTable() |
This method should be called only once after
fetchCellAttr | |
public java.lang.Object fetchCellAttr(int key) |
fetchInheritedCellAttr | |
public java.lang.Object fetchInheritedCellAttr(int key) |
fetchInheritedRowAttr | |
public java.lang.Object fetchInheritedRowAttr(int key) |
fetchInheritedRunAttr | |
public java.lang.Object fetchInheritedRunAttr(int fontAttr) |
fetchRowAttr | |
public java.lang.Object fetchRowAttr(int key) |
getDirectCellAttr | |
public java.lang.Object getDirectCellAttr(int key) |
getDirectRowAttr | |
public java.lang.Object getDirectRowAttr(int key) |
getDirectRunAttr | |
public java.lang.Object getDirectRunAttr(int fontAttr) |
getDirectRunAttrsCount | |
public int getDirectRunAttrsCount() |
insertBreak | |
public void insertBreak(int breakType) |
breakType
- A insertCell | |
public Aspose.Words.Tables.Cell insertCell() |
To start a table, just call InsertCell. After this, any content you add using
other methods of the
To start a new cell in the same row, call InsertCell again.
To end a table row call
Use the
insertCheckBox | |
public Aspose.Words.Fields.FormField insertCheckBox(java.lang.String name, boolean defaultValue, boolean checkedValue, int size) throws java.lang.Exception |
If you specify a name for the form field, then a bookmark is automatically created with the same name.
name
- The name of the form field. Can be an empty string.defaultValue
- Default value of the checkbox form field.checkedValue
- Current checked status of the checkbox form field.size
- Specifies the size of the checkbox in points. Specify 0 for MS Word
to calculate the size of the checkbox automatically.insertCheckBox | |
public Aspose.Words.Fields.FormField insertCheckBox(java.lang.String name, boolean checkedValue, int size) throws java.lang.Exception |
If you specify a name for the form field, then a bookmark is automatically created with the same name.
name
- The name of the form field. Can be an empty string.checkedValue
- Checked status of the checkbox form field.size
- Specifies the size of the checkbox in points. Specify 0 for MS Word
to calculate the size of the checkbox automatically.insertComboBox | |
public Aspose.Words.Fields.FormField insertComboBox(java.lang.String name, java.lang.String[] items, int selectedIndex) throws java.lang.Exception |
If you specify a name for the form field, then a bookmark is automatically created with the same name.
name
- The name of the form field. Can be an empty string.items
- The items of the ComboBox. Maximum is 25 items.selectedIndex
- The index of the selected item in the ComboBox.insertDocument | |
public Node insertDocument(Document srcDoc, int importFormatMode) |
srcDoc
- Source document for inserting.importFormatMode
- A insertField | |
public Aspose.Words.Fields.Field insertField(java.lang.String fieldCode) throws java.lang.Exception |
This method inserts a field into a document and updates the field result immediately.
Aspose.Words can update fields of most types, but not all. For more details see the
fieldCode
- The field code to insert (without curly braces).insertField | |
public Aspose.Words.Fields.Field insertField(java.lang.String fieldCode, java.lang.String fieldValue) |
Fields in Microsoft Word documents consist of a field code and a field result. The field code is like a formula and the field result is like the value that the formula produces. The field code may also contain field switches that are like additional instructions to perform a specific action.
You can switch between displaying field codes and results in your document in Microsoft Word using the keyboard shortcut Alt+F9. Field codes appear between curly braces ( { } ).
To create a field, you need to specify a field type, field code and a "placeholder" field value. If you are not sure about a particular field code syntax, create the field in Microsoft Word first and switch to see its field code.
Aspose.Words can calculate field results for most of the field types, but this method
does not update the field result automatically. Because the field result is not calculated automatically,
you are expected to pass some string value (or even an empty string) that will be inserted into the field result.
This value will remain in the field result as a placeholder until the field is updated.
To update the field result you can call
fieldCode
- The field code to insert (without curly braces).fieldValue
- The field value to insert. Pass null for fields that do not have a value.insertFootnote | |
public Footnote insertFootnote(int footnoteType, java.lang.String footnoteText) |
footnoteType
- A footnoteText
- Specifies the text of the footnote.insertFootnote | |
public Footnote insertFootnote(int footnoteType, java.lang.String footnoteText, java.lang.String referenceMark) |
footnoteType
- A footnoteText
- Specifies the text of the footnote.referenceMark
- Specifies the custom reference mark of the footnote.insertHtml | |
public void insertHtml(java.lang.String html) throws java.lang.Exception |
You can use InsertHtml to insert an HTML fragment or whole HTML document.
html
- An HTML string to insert into the document.insertHtml | |
public void insertHtml(java.lang.String html, boolean useBuilderFormatting) throws java.lang.Exception |
You can use InsertHtml to insert an HTML fragment or whole HTML document.
When useBuilderFormatting is false
,
When useBuilderFormatting is true
,
formatting of inserted text is based on
html
- An HTML string to insert into the document.useBuilderFormatting
-
A value indicating whether formatting specified in insertHyperlink | |
public Aspose.Words.Fields.Field insertHyperlink(java.lang.String displayText, java.lang.String urlOrBookmark, boolean isBookmark) |
Note that you need to specify font formatting for the hyperlink display text explicitly
using the
This methods internally calls
displayText
- Text of the link to be displayed in the document.urlOrBookmark
- Link destination. Can be a url or a name of a bookmark inside the document.
This method always adds apostrophes at the beginning and end of the url.isBookmark
- True if the previous parameter is a name of a bookmark inside the document;
false is the previous parameter is a URL.insertImage | |
public Shape insertImage(byte[] imageBytes) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
imageBytes
- The byte array that contains the image.insertImage | |
public Shape insertImage(byte[] imageBytes, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
imageBytes
- The byte array that contains the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.insertImage | |
public Shape insertImage(byte[] imageBytes, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
imageBytes
- The byte array that contains the image.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.wrapType
- A insertImage | |
public Shape insertImage(java.io.InputStream stream) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
stream
- The stream that contains the image.
The stream will be read from the current position, so one should be careful about stream position.insertImage | |
public Shape insertImage(java.io.InputStream stream, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
stream
- The stream that contains the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.insertImage | |
public Shape insertImage(java.io.InputStream stream, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
stream
- The stream that contains the image.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.wrapType
- A insertImage | |
public Shape insertImage(java.lang.String fileName) throws java.lang.Exception |
This overload will automatically download the image before inserting into the document if you specify a remote URI.
You can change the image size, location, positioning method and other settings using the
fileName
- The file with the image. Can be any valid local or remote URI.insertImage | |
public Shape insertImage(java.lang.String fileName, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
fileName
- The file that contains the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.insertImage | |
public Shape insertImage(java.lang.String fileName, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
fileName
- The file that contains the image.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.wrapType
- A insertNode | |
public void insertNode(Node node) |
insertOnlineVideo | |
public Shape insertOnlineVideo(java.lang.String videoUrl, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
Insertion of online video from the following resources is supported:
If your online video is not displaying correctly, use
The code for embedding video can vary between providers, consult your corresponding provider of choice for details.
videoUrl
- The URL to the video.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.insertOnlineVideo | |
public Shape insertOnlineVideo(java.lang.String videoUrl, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
Insertion of online video from the following resources is supported:
If your online video is not displaying correctly, use
The code for embedding video can vary between providers, consult your corresponding provider of choice for details.
videoUrl
- The URL to the video.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.wrapType
- A insertOnlineVideo | |
public Shape insertOnlineVideo(java.lang.String videoUrl, java.lang.String videoEmbedCode, byte[] thumbnailImageBytes, double width, double height) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
videoUrl
- The URL to the video.videoEmbedCode
- The embed code for the video.thumbnailImageBytes
- The thumbnail image bytes.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.insertOnlineVideo | |
public Shape insertOnlineVideo(java.lang.String videoUrl, java.lang.String videoEmbedCode, byte[] thumbnailImageBytes, int horzPos, double left, int vertPos, double top, double width, double height, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
videoUrl
- The URL to the video.videoEmbedCode
- The embed code for the video.thumbnailImageBytes
- The thumbnail image bytes.horzPos
- A left
- Distance in points from the origin to the left side of the image.vertPos
- A top
- Distance in points from the origin to the top side of the image.width
- The width of the image in points. Can be a negative or zero value to request 100% scale.height
- The height of the image in points. Can be a negative or zero value to request 100% scale.wrapType
- A insertParagraph | |
public Paragraph insertParagraph() |
Current paragraph formatting specified by the
Breaks the current paragraph in two. After inserting the paragraph, the cursor is placed at the beginning of the new paragraph.
insertSignatureLine | |
public Shape insertSignatureLine(SignatureLineOptions signatureLineOptions) throws java.lang.Exception |
signatureLineOptions
- The object that stores parameters of creating signature line.insertSignatureLine | |
public Shape insertSignatureLine(SignatureLineOptions signatureLineOptions, int horzPos, double left, int vertPos, double top, int wrapType) throws java.lang.Exception |
You can change the image size, location, positioning method and other settings using the
Aspose.Words will insert the image in the PNG format and with default settings. If you want to insert a BufferedImage in
another format or with other settings, you need to save the image into a byte array and use
signatureLineOptions
- The object that stores parameters of creating signature line.horzPos
- A left
- Distance in points from the origin to the left side of the signature line.vertPos
- A top
- Distance in points from the origin to the top side of the signature line.wrapType
- A insertTableOfContents | |
public Aspose.Words.Fields.Field insertTableOfContents(java.lang.String switches) |
This method inserts a TOC (table of contents) field into the document at the current position.
A table of contents in a Word document can be built in a number of ways and formatted using a variety of options. The way the table is built and displayed by Microsoft Word is controlled by the field switches.
The easiest way to specify the switches is to insert and configure a table of contents into a Word document using the Insert->Reference->Index and Tables menu, then switch display of field codes on to see the switches. You can press Alt+F9 in Microsoft Word to toggle display of field codes on or off.
For example, after creating a table of contents, the following field is inserted into the document: { TOC \o "1-3" \h \z \u }. You can copy \o "1-3" \h \z \u and use it as the switches parameter.
Note that InsertTableOfContents will only insert a TOC field, but will not actually build the table of contents. The table of contents is built by Microsoft Word when the field is updated.
If you insert a table of contents using this method and then open the file in Microsoft Word, you will not see the table of contents because the TOC field has not yet been updated.
In Microsoft Word, fields are not automatically updated when a document is opened, but you can update fields in a document at any time by pressing F9.
switches
- The TOC field switches.moveTo | |
public void moveTo(Node node) |
When node is an inline-level node, the cursor is moved to this node and further content will be inserted before that node.
When node is a Paragraph, the cursor is moved to the end of the paragraph and further content will be inserted just before the paragraph break.
When node is a block-level node but not a Paragraph, the cursor is moved to the end of the first paragraph into block-level node and further content will be inserted just before the paragraph break.
node
- The node must be a paragraph or a direct child of a paragraph.moveToBookmark | |
public boolean moveToBookmark(java.lang.String bookmarkName) throws java.lang.Exception |
Moves the cursor to a position just after the start of the bookmark with the specified name.
The comparison is not case-sensitive. If the bookmark was not found, false is returned and the cursor is not moved.
Inserting new text does not replace existing text of the bookmark.
Note that some bookmarks in the document are assigned to form fields. Moving to such a bookmark and inserting text there inserts the text into the form field code. Although this will not invalidate the form field, the inserted text will not be visible because it becomes part of the field code.
bookmarkName
- The name of the bookmark to move the cursor to.moveToBookmark | |
public boolean moveToBookmark(java.lang.String bookmarkName, boolean isStart, boolean isAfter) throws java.lang.Exception |
Moves the cursor to a position before or after the bookmark start or end.
The comparison is not case-sensitive. If the bookmark was not found, false is returned and the cursor is not moved.
bookmarkName
- The name of the bookmark to move the cursor to.isStart
- When true, moves the cursor to the beginning of the bookmark.
When false, moves the cursor to the end of the bookmark.isAfter
- When true, moves the cursor to be after the bookmark
start or end position. When false, moves the cursor to be before the bookmark
start or end position.moveToCell | |
public void moveToCell(int tableIndex, int rowIndex, int columnIndex, int characterIndex) |
The navigation is performed inside the current story of the current section.
For the index parameters, when index is greater than or equal to 0, it specifies an index from the beginning with 0 being the first element. When index is less than 0, it specified an index from the end with -1 being the last element.
tableIndex
- The index of the table to move to.rowIndex
- The index of the row in the table.columnIndex
- The index of the column in the table.characterIndex
- The index of the character inside the cell.
Currently can only specify 0 to move to the beginning of the cell or -1 to
move to the end of the cell.moveToDocumentEnd | |
public void moveToDocumentEnd() |
moveToDocumentStart | |
public void moveToDocumentStart() |
moveToHeaderFooter | |
public void moveToHeaderFooter(int headerFooterType) |
After you moved the cursor into a header or footer, you can use the rest of DocumentBuilder methods to modify the contents of the header or footer.
If you want to create headers and footers different for the first page, you need
to set
If you want to create headers and footers different for even and odd pages, you need
to set
Use
headerFooterType
- A moveToMergeField | |
public boolean moveToMergeField(java.lang.String fieldName) throws java.lang.Exception |
Note that this method deletes the merge field from the document after moving the cursor.
fieldName
- The case-insensitive name of the mail merge field.moveToMergeField | |
public boolean moveToMergeField(java.lang.String fieldName, boolean isAfter, boolean isDeleteField) throws java.lang.Exception |
fieldName
- The case-insensitive name of the mail merge field.isAfter
- When true, moves the cursor to be after the field end.
When false, moves the cursor to be before the field start. isDeleteField
- When true, deletes the merge field.moveToParagraph | |
public void moveToParagraph(int paragraphIndex, int characterIndex) |
The navigation is performed inside the current story of the current section. That is, if you moved the cursor to the primary header of the first section, then paragraphIndex specified the index of the paragraph inside that header of that section.
When paragraphIndex is greater than or equal to 0, it specifies an index from the beginning of the section with 0 being the first paragraph. When paragraphIndex is less than 0, it specified an index from the end of the section with -1 being the last paragraph.
paragraphIndex
- The index of the paragraph to move to.characterIndex
- The index of the character inside the paragraph.
Currently can only specify 0 to move to the beginning of the paragraph or -1 to
move to the end of the paragraph.
moveToSection | |
public void moveToSection(int sectionIndex) |
When sectionIndex is greater than or equal to 0, it specifies an index from the beginning of the document with 0 being the first section. When sectionIndex is less than 0, it specified an index from the end of the document with -1 being the last section.
The cursor is moved to the first paragraph in the Body of the specified section.
sectionIndex
- The index of the section to move to.popFont | |
public void popFont() |
pushFont | |
public void pushFont() |
removeRunAttr | |
public void removeRunAttr(int key) |
resetToDefaultAttrs | |
public void resetToDefaultAttrs() |
setCellAttr | |
public void setCellAttr(int key, java.lang.Object value) |
setRowAttr | |
public void setRowAttr(int key, java.lang.Object value) |
setRunAttr | |
public void setRunAttr(int fontAttr, java.lang.Object value) |
startBookmark | |
public BookmarkStart startBookmark(java.lang.String bookmarkName) |
Bookmarks in a document can overlap and span any range. To create a valid bookmark you need to
call both
Badly formed bookmarks or bookmarks with duplicate names will be ignored when the document is saved.
bookmarkName
- Name of the bookmark.startEditableRange | |
public EditableRangeStart startEditableRange() |
Editable range in a document can overlap and span any range. To create a valid editable range you need to
call both
Badly formed editable range will be ignored when the document is saved.
startTable | |
public Aspose.Words.Tables.Table startTable() |
The next method to call is
This method starts a nested table when called inside a cell.
write | |
public void write(java.lang.String text) |
text
- The string to insert into the document.writeln | |
public void writeln() |
Calls
writeln | |
public void writeln(java.lang.String text) |
text
- The string to insert into the document.