Hi
I have a word paper document . Every question has its number .
Some numbers are entered manually, it is of course parsed into a Paragraph by aspose.
However , some numbers are generated using the word numbering function that comes with the word .
How can I read or set the part?
Hi,
Thanks for your inquiry. Please see attached sample Word document and try running the following code:
Document doc = new Document("D:\\temp\\Q1.docx");
doc.updateListLabels();
for(Paragraph para : (Iterable) doc.getChildNodes(NodeType.PARAGRAPH, true))
{
if (para.isListItem())
{
System.out.println(para.getListLabel().getLabelString());
}
}
Also, please see ListLevel, List, ListFormat classes. Hope, this helps.
Best regards,
Thank you very much.
I have see these classes,but i still don’t know how to delete the list
Hi,
Thanks for your inquiry. Please try using the following code:
Document doc = new Document("D:\temp\Q1.docx");
// Code to remove list labels from the start of Paragraphs
// for(Paragraph para : (Iterable) doc.getChildNodes(NodeType.PARAGRAPH, true)) {
// if (para.isListItem()) {
// para.getListFormat().setList(null);
// }
// }
// Code to remove list Paragraphs
for (Paragraph para : (Iterable)doc.getChildNodes(NodeType.PARAGRAPH, true))
{
if (para.isListItem())
{
para.remove();
}
}
doc.save("D:\temp\awjava-17.3.docx");
Hope, this helps.
Best regards,
Hi
I want to delete this list instead of deleting the paragraph
In addition , I wondered why my server always reported a memory leak error that was about aspose, whether or not aspose had something to be closed
Thank you very much
Hi,
Thanks for your inquiry. Regarding the memory leak problem, please upgrade to the latest version of Aspose.Words for Java from the following link. Hope, this helps.
https://downloads.aspose.com/words/java
Secondly, please try using the following code:
Document doc = new Document("D:\temp\Q1.docx");
// Code to remove list labels from the start of Paragraphs
for (Paragraph para : (Iterable)doc.getChildNodes(NodeType.PARAGRAPH, true))
{
if (para.isListItem())
{
para.getListFormat().setList(null);
}
}
doc.removeUnusedResources();
doc.save("D:\temp\awjava-17.3.docx");
Best regards,