plutext / docx4j

JAXB-based Java library for Word docx, Powerpoint pptx, and Excel xlsx files
https://www.docx4java.org/
2.12k stars 1.2k forks source link

Unable to generate Flat XML for docx containing a diagram #567

Closed urieli closed 9 months ago

urieli commented 10 months ago

docx4j version: 11.4.9

Trying to convert this docx document to Flat OPC (FlatXML) format: Test_Diag_ContenuModif.docx

When attempting to call Docx4J.save(wmlPackage, new FileOutputStream(destinationFile), Docx4J.FLAG_SAVE_FLAT_XML); I get the error below:

Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.addPartsFromRelationships(FlatOpcXmlCreator.java:567)
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.populate(FlatOpcXmlCreator.java:143)
    at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:749)
    at org.docx4j.openpackaging.packages.OpcPackage.save(OpcPackage.java:729)
    at org.docx4j.Docx4J.save(Docx4J.java:294)
    ... 9 more
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.addPartsFromRelationships(FlatOpcXmlCreator.java:567)
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.savePart(FlatOpcXmlCreator.java:615)
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.addPartsFromRelationships(FlatOpcXmlCreator.java:562)
    ... 14 more
Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Failed to add parts from relationships
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.addPartsFromRelationships(FlatOpcXmlCreator.java:567)
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.savePart(FlatOpcXmlCreator.java:615)
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.addPartsFromRelationships(FlatOpcXmlCreator.java:562)
    ... 16 more
Caused by: org.docx4j.openpackaging.exceptions.InvalidFormatException: A segment shall not hold any characters other than pchar characters. [M1.6]
    at org.docx4j.openpackaging.parts.PartName.checkPCharCompliance(PartName.java:428)
    at org.docx4j.openpackaging.parts.PartName.throwExceptionIfPartNameHaveInvalidSegments(PartName.java:322)
    at org.docx4j.openpackaging.parts.PartName.throwExceptionIfInvalidPartUri(PartName.java:228)
    at org.docx4j.openpackaging.parts.PartName.<init>(PartName.java:161)
    at org.docx4j.openpackaging.parts.PartName.<init>(PartName.java:133)
    at org.docx4j.convert.out.flatOpcXml.FlatOpcXmlCreator.addPartsFromRelationships(FlatOpcXmlCreator.java:554)
    ... 18 more

However, the document seems to be a valid word document, and opens correctly without any errors in Microsoft Word.l