Page 1 of 1

Online Demo PartsList Generated Java Code

PostPosted: Mon Jun 07, 2021 9:29 pm
by gengstah

I am trying out the Java code generated in but I am getting the error below:
Word found unreadable content in helloworld.docx Do you want to recover the contents of this document? ...

I attached the template I wish to use in this post and I am saving the document like so:
Code: Select all
public class Foo {
   public static void main(String[] args) throws Exception {
      // Create the package
      WordprocessingMLPackage wordMLPackage = new WordprocessingMLPackage();
      // Create the main document part (word/document.xml)
      MainDocumentPart wordDocumentPart = new MainDocumentPart();
      // Create main document part content
      //ObjectFactory factory = Context.getWmlObjectFactory();
      //org.docx4j.wml.Body body = factory.createBody();
      org.docx4j.wml.Document wmlDocumentEl = createIt();
      // Put the content in the part
      // Add the main document part to the package relationships// (creating it if necessary)
      // Save it"helloworld.docx") );
   public static Document createIt() {


      return document;

Is there anything I missed? I just copied and pasted the generated Java code from PartsListt