Corrupt word doc - perhaps recent word update?
Posted: Thu Feb 20, 2020 8:39 am
Hi there,
Im seeing an increasing number of issues where files on some versions of word/windows when processed through docx4j (code sample below), produce a corrupt file. I've attached the main document.xml that contains loads of extra namespaces which (i think) but I'm not 100% sure could be causing this.
To replicate this, all I need to do is do something like:
I'm seeing this on the latest version 8.1.4 and it only started appearing for us in the last week or so.
Im seeing an increasing number of issues where files on some versions of word/windows when processed through docx4j (code sample below), produce a corrupt file. I've attached the main document.xml that contains loads of extra namespaces which (i think) but I'm not 100% sure could be causing this.
To replicate this, all I need to do is do something like:
- Code: Select all
WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(doc)
HashMap<PartName, Part> parts = wordMLPackage.parts.parts
parts.each { PartName name, Part part ->
boolean process = part instanceof MainDocumentPart // ||part instanceof HeaderPart || part instanceof FooterPart
if (process) {
processPart((ContentAccessor)part, placeholders)
}
}
try {
wordMLPackage.save(doc)
}
private void processPart(ContentAccessor documentPart, List<DocuSignPlaceHolder> placeholders)
{
ClassFinder finder = new ClassFinder(Text)
new TraversalUtil(documentPart.getContent(), finder)
// other code removed for simplicity.
}
I'm seeing this on the latest version 8.1.4 and it only started appearing for us in the last week or so.