Page 1 of 1

Error while converting doc to pdf

PostPosted: Wed Sep 23, 2015 8:02 pm
by silvestrelosada
I'm getting this exception if I try to convert doc file to pdf. The code is working well with most of documents however when processing some of them next exception is thrown.

org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:109)
at org.docx4j.Docx4J.toFO(Docx4J.java:466)
at org.docx4j.Docx4J.toPDF(Docx4J.java:480)
at org.apache.update.docconverter.DocToPDF.convert(DocToPDFConverter.java:68)

Caused by: org.docx4j.openpackaging.exceptions.Docx4JException: Exception executing transformer: org.apache.fop.fo.ValidationException: The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table. (See position 3:11333)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:215)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:158)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:139)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)



here is my code
Code: Select all
     //istream intput stream to doc
     WordprocessingMLPackage mlPackage = Doc.convert(iStream);
// os contains output stream for pdf
      Docx4J.toPDF(wordMLPackage, os);


Re: Error while converting doc to pdf

PostPosted: Thu Sep 24, 2015 9:19 am
by jason
silvestrelosada wrote:fo.ValidationException: The column-number or number of cells in the row overflows the number of fo:table-columns specified for the table. (See position 3:11333)


You should produce a minimal docx from a problematic one which reproduces the error.

I'd expect this to contain a single table.

Either you've created a table which is mal-formed (which presumably Word is nevertheless happy with), or there is a problem in the docx-fo-pdf pipeline.

You should try editing the docx in Word, then generating PDF, to see if Word "fixes" it.

If does fix it, you know the problem is in your OpenXML; you need to hand edit the XML (easy in VisualStudio, with the OpenXML tool) to get your minimal docx. But then you can easily compare your table with Word's, to see what is broken.

If Word doesn't fix it, well, you can probably use Word to delete content to get your minimal docx. That minimal docx can then be used as a test case to improve docx4j.

Note: the error message also tells you where in the intermediate XSL FO the problem is detected. If you save that, you can (1) look there for a hint as to where the error is, and (2) hand edit the XSL FO and feed it to FOP, to work out what change is necessary to make FOP happy.

Re: Error while converting doc to pdf

PostPosted: Thu Sep 24, 2015 6:54 pm
by silvestrelosada
Thanks for your answer!!