Page 1 of 1

Document "losing" content

PostPosted: Wed Apr 20, 2016 10:20 pm
by wschofield
All,

I have very strange scenario in that I have Java Spring Boot application which uses docx4j to read in a docx template, modify the content, and save the result as a docx file. When I start up the application, the first time I generate a document it works correctly. However, if the attempt to generate another one, the resulting document is corrupted, primarily by dropping text boxes and graphic images in the template.

As an experiment, I just loaded the document and then saved it, with no edits in between. The resulting document was different from the original in the same way.

Architecturally, the class is instantiated each run and its reference is set to null at the end. I have to be getting a new object each time so I don't believe it is old data from the previous document corrupting the generation of the second one.

I've tried increasing the memory of the JVM but that doesn't seem to help. The logs, the voluminous logs, don't seem to show a problem but I'm really not sure what I'm looking for.

Any ideas on this mystery would be greatly appreciated!

Wade

wordMLPackage = WordprocessingMLPackage.load(file);
documentPart = wordMLPackage.getMainDocumentPart();
.
.
.
<change content>
.
.
wordMLPackage.save(new File(reportFolder + name + ".docx"));

Re: Document "losing" content

PostPosted: Wed Apr 20, 2016 11:30 pm
by jason

Re: Document "losing" content

PostPosted: Fri Apr 22, 2016 12:10 pm
by wschofield
You rock Jason! I changed my Maven POM to point to 3.3.0 and it works beautifully! Now, I have just one more bug to work through but I'll post that in a different post.