First of all, thank you for docx4j as it is an amazing tool!
I am trying to copy a section of a docx and export it to an html document. Images, headings and lists are working well, but when I try to add a simple table (with no borders and no format), I receive the following error:
- Code: Select all
Caused by: java.lang.NullPointerException
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.getCellPStyle(ParagraphStylesInTableFix.java:250)
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.apply(ParagraphStylesInTableFix.java:555)
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.walkJAXBElements(ParagraphStylesInTableFix.java:590)
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.walkJAXBElements(ParagraphStylesInTableFix.java:597)
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.walkJAXBElements(ParagraphStylesInTableFix.java:597)
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix$StyleRenamer.walkJAXBElements(ParagraphStylesInTableFix.java:597)
at org.docx4j.TraversalUtil.<init>(TraversalUtil.java:209)
at org.docx4j.convert.out.common.preprocess.ParagraphStylesInTableFix.process(ParagraphStylesInTableFix.java:156)
at org.docx4j.convert.out.common.Preprocess.process(Preprocess.java:179)
at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractWmlExporter.java:51)
at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractWmlExporter.java:32)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:63)
And this is part of the code:
- Code: Select all
List<Object> listOfTables= getAllElementFromObject(wordMLPackage.getMainDocumentPart(), Tbl.class);
wordMLPackage2.getMainDocumentPart().addObject(listOfTables.get((0)));
HTMLSettings htmlSettings = Docx4J.createHTMLSettings();
htmlSettings.setImageDirPath(htmlmediafolder);
htmlSettings.setImageTargetUri(htmlmediafolder);
htmlSettings.setWmlPackage(wordMLPackage2);
// For testing purposes
wordMLPackage2.save(new java.io.File(outputfolder + "/HelloWord.docx"));
OutputStream os = new FileOutputStream(outputfolder + "/sampleout.html");
[b]Docx4J.toHTML(htmlSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);[/b]
The "HelloWord.docx" document is working OK. Any ideas?
Thanks in advance,
Ismael