If I check the number of words directly in the word file, it is 16814 characters, but if I read the number of words in the library, it is 16816 characters.
try_1
Document doc = new Document(path);
doc.updateWordCount();
doc.updatePageLayout();
doc.getBuiltInDocumentProperties().getWords(); // return 16816
try_2
Document doc = new Document(path);
for (Run run : (Iterable) doc.getChildNodes(NodeType.RUN, true)){
if(run.getFont().getHidden())
run.remove();
}
doc.updateWordCount();
doc.updatePageLayout();
doc.getBuiltInDocumentProperties().getWords(); // return 16816
Here is my word file :
wrong.docx (163.4 KB)