centic9 commented on PR #458:
URL: https://github.com/apache/poi/pull/458#issuecomment-1518549715
The duplication seems to be because of the "AlternatContent" (i.e. MSs way
of not changing the spec, but still adding new types of content ...).
Can you try to add the following between opening the document and adding
content? I am not 100% sure this is really the issue, so please verify that
Microsoft Word can then read the document properly.
This can also be used as workaround if it is really fixing the issue.
```
for (XWPFParagraph paragraph : document.getParagraphs()) {
for (XWPFRun run : paragraph.getRuns()) {
XmlCursor cursor = run.getCTR().newCursor();
cursor.selectPath("declare namespace
w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' "
+ "declare namespace
mc='http://schemas.openxmlformats.org/markup-compatibility/2006' "
+ "declare namespace
wp='http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing' "
+
".//mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:docPr");
while(cursor.hasNextSelection()) {
cursor.toNextSelection();
XmlObject obj = cursor.getObject();
CTNonVisualDrawingProps docPr =
CTNonVisualDrawingProps.Factory.parse(obj.xmlText());
document.getDrawingIdManager().reserve(docPr.getId());
}
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]