Page 1 of 1

docx created in OpenOffice

PostPosted: Tue Sep 21, 2010 8:53 am
by sperruolo
Hi, I'm having this NullPointerException trying to convert a docx to html:

java.lang.NullPointerException
at org.docx4j.model.PropertyResolver.init(PropertyResolver.java:193)
at org.docx4j.model.PropertyResolver.<init>(PropertyResolver.java:161)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.getPropertyResolver(MainDocumentPart.java:177)


My java code is
Code: Select all
public static String convert2HTML(File docxFile, String target) throws Exception {
      
      String fileName = removeFileExtension(docxFile) + ".html";
      WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(docxFile);
      try {
         wordMLPackage.getMainDocumentPart().getPropertyResolver();
      } catch (Exception e) {
         LoggerManager.getLogger(Docx4jUtils.class).error("Error", e);
         return "error/propertyResolver.html";
      }
      
       AbstractHtmlExporter exporter = new HtmlExporterNG2();
       // note the *2* there

       // Write to StreamResult (in this case, an output stream)
       OutputStream os = new java.io.FileOutputStream(target + fileName);
       javax.xml.transform.stream.StreamResult result
          = new javax.xml.transform.stream.StreamResult(os);

       exporter.html(wordMLPackage, result, target + "_files");
       return fileName;
   }


I hope you guys can help me.

Re: NullPointerException at PropertyResolver.init()

PostPosted: Tue Sep 21, 2010 9:37 am
by jason
Could you please post a docx exhibiting the problem? (You'll need to rename it to .zip in order to attach it).

Re: NullPointerException at PropertyResolver.init()

PostPosted: Tue Nov 09, 2010 1:39 am
by sperruolo
I was using a docx document created with OpenOffice, that's why I'm having the problem. Thanks anyway!

Re: NullPointerException at PropertyResolver.init()

PostPosted: Tue Nov 09, 2010 7:34 am
by jason
Most OpenOffice docx should work if you use a recent docx4j nightly build.

There are some known issues, which I reported to Novell some 8 months ago. The most important:

* wp namespace missing in header containing image https://bugzilla.novell.com/show_bug.cgi?id=581954