public class ListLabel
extends java.lang.Object
To learn more, visit the Working with Lists documentation article.
Examples:
Shows how to extract the list labels of all paragraphs that are list items.
Document doc = new Document(getMyDir() + "Rendering.docx"); doc.updateListLabels(); int listParaCount = 1; for (Paragraph paragraph : (Iterable) doc.getChildNodes(NodeType.PARAGRAPH, true)) { // Find if we have the paragraph list. In our document, our list uses plain Arabic numbers, // which start at three and ends at six. if (paragraph.getListFormat().isListItem()) { System.out.println(MessageFormat.format("List item paragraph #{0}", listParaCount)); // This is the text we get when getting when we output this node to text format. // This text output will omit list labels. Trim any paragraph formatting characters. String paragraphText = paragraph.toString(SaveFormat.TEXT).trim(); System.out.println("Exported Text: " + paragraphText); ListLabel label = paragraph.getListLabel(); // This gets the position of the paragraph in the current level of the list. If we have a list with multiple levels, // this will tell us what position it is on that level. System.out.println("\tNumerical Id: {label.LabelValue}"); // Combine them together to include the list label with the text in the output. System.out.println("\tList label combined with text: {label.LabelString} {paragraphText}"); } }
| Modifier and Type | Method and Description |
|---|---|
void |
clearRunAttrs() |
java.lang.Object |
fetchInheritedRunAttr(int key) |
java.lang.Object |
getDirectRunAttr(int key) |
java.lang.Object |
getDirectRunAttr(int key,
int revisionsView) |
Font |
getFont()
Gets the list label font.
|
java.lang.String |
getLabelString()
Gets a string representation of list label.
|
int |
getLabelValue()
Gets a numeric value for this label.
|
void |
removeRunAttr(int key) |
void |
setRunAttr(int key,
java.lang.Object value) |
public Font getFont()
public java.lang.String getLabelString()
Examples:
Shows how to extract the list labels of all paragraphs that are list items.
Document doc = new Document(getMyDir() + "Rendering.docx"); doc.updateListLabels(); int listParaCount = 1; for (Paragraph paragraph : (Iterable) doc.getChildNodes(NodeType.PARAGRAPH, true)) { // Find if we have the paragraph list. In our document, our list uses plain Arabic numbers, // which start at three and ends at six. if (paragraph.getListFormat().isListItem()) { System.out.println(MessageFormat.format("List item paragraph #{0}", listParaCount)); // This is the text we get when getting when we output this node to text format. // This text output will omit list labels. Trim any paragraph formatting characters. String paragraphText = paragraph.toString(SaveFormat.TEXT).trim(); System.out.println("Exported Text: " + paragraphText); ListLabel label = paragraph.getListLabel(); // This gets the position of the paragraph in the current level of the list. If we have a list with multiple levels, // this will tell us what position it is on that level. System.out.println("\tNumerical Id: {label.LabelValue}"); // Combine them together to include the list label with the text in the output. System.out.println("\tList label combined with text: {label.LabelString} {paragraphText}"); } }
public int getLabelValue()
Remarks:
Use the Document.updateListLabels() method to update the value of this property.
Examples:
Shows how to extract the list labels of all paragraphs that are list items.
Document doc = new Document(getMyDir() + "Rendering.docx"); doc.updateListLabels(); int listParaCount = 1; for (Paragraph paragraph : (Iterable) doc.getChildNodes(NodeType.PARAGRAPH, true)) { // Find if we have the paragraph list. In our document, our list uses plain Arabic numbers, // which start at three and ends at six. if (paragraph.getListFormat().isListItem()) { System.out.println(MessageFormat.format("List item paragraph #{0}", listParaCount)); // This is the text we get when getting when we output this node to text format. // This text output will omit list labels. Trim any paragraph formatting characters. String paragraphText = paragraph.toString(SaveFormat.TEXT).trim(); System.out.println("Exported Text: " + paragraphText); ListLabel label = paragraph.getListLabel(); // This gets the position of the paragraph in the current level of the list. If we have a list with multiple levels, // this will tell us what position it is on that level. System.out.println("\tNumerical Id: {label.LabelValue}"); // Combine them together to include the list label with the text in the output. System.out.println("\tList label combined with text: {label.LabelString} {paragraphText}"); } }
public java.lang.Object getDirectRunAttr(int key)
public java.lang.Object getDirectRunAttr(int key,
int revisionsView)
public java.lang.Object fetchInheritedRunAttr(int key)
public void setRunAttr(int key,
java.lang.Object value)
public void removeRunAttr(int key)
public void clearRunAttrs()