Hi,
I want to count paragraphs with this code (JAVA) :
int nParagraph=0;
com.aspose.words.NodeCollection children = doc.getChildNodes(com.aspose.words.NodeType.PARAGRAPH, true);
for (com.aspose.words.Paragraph paragraph : (Iterable<com.aspose.words.Paragraph>) children) {
if (!StringUtils.isEmpty(paragraph.getText())) {
System.out.println(":::::PARAGRAPH:::::"+paragraph.getText());
nParagraph++;
}
}
System.out.println(":::::COUNT PARAGRAPH:::::"+nParagraph);
System.out.println(":::::COUNT PARAGRAPH:::::"+doc.getChildNodes(com.aspose.words.NodeType.PARAGRAPH, true).getCount());
And the results are not equal to MS-Word. I found that because it include empty paragraphs, I handled this issue by filter empty paragraphs out, and there are duplicated paragraphs as attached pictures.
Is there a way to fix the duplicated paragraph? Please advise.
Regards
Screenshot from 2020-08-14 16-43-31.png (23.5 KB)
Screenshot from 2020-08-14 17-14-59.png (50.2 KB)
sample.zip (136.6 KB)