Hello,
when using sensitivity labels in Word, I noticed that parts of a document generated with Aspose.Words (24.1) are displayed twice.
I have only noticed this in one organization so far. The function sensitivity labels seems to be different in organizations.
The reason for this are w14:paraIds that are not unique in the document. According to the documentation, the w14:paraId should be unique: [MS-DOCX]: paraId | Microsoft Learn. If the IDs are changed manually in the XML after saving, the parts are not displayed twice.
Why are there duplicate IDs in the document? Two table rows were duplicated in the document using Node.deepClone(). deepClone also seems to copy the w14:paraId attribute.
Steps to reproduce:
template.docx (37.3 KB)
The attached document is loaded and the two table rows are copied with the following code.
Document doc = new Document("..\\template.docx");
NodeCollection<Row> rows = doc.getChildNodes(NodeType.ROW, true);
Node refNode = rows.get(0);
for (Node row : rows) {
Node clone = row.deepClone(true);
refNode.getParentNode().insertBefore(clone, refNode);
}
doc.save("..\\test.docx");
In the saved document, you can see in the document.xml file that the w14:paraIds in the table are not unique.
Further findings
I have found WORDSNET-21436. With a version prior to 20.12, the w14:paraIds are actually unique.
Solution Idea
Is it possible to access the w14:paraIds and change them?
Is it correct that the w14:paraIds are also copied when using deepClone?
Is it possible to remove the w14:paraIds when saving a document (SaveOptions)?
Best regards
Ingo