Doc4j - Having issues converting docx to PDF with tables in the document

妖精的绣舞 提交于 2019-12-08 13:42:39

问题


I just tried to a docx document through docx4j's sample webapp at: http://webapp.docx4java.org/OnlineDemo/docx_to_pdf_fop.html the resulting PDF file had the tables incorrectly formatted. In fact the tables were significantly off...

I'm just wondering if it's because docx4j doesn't properly support tables or it's an error of some sort. And if so, if anyone could point me to the proper information.


回答1:


https://github.com/plutext/docx4j/blob/master/sample-docs/word/tables.docx is an example of various table features we can process.

Without seeing your docx (and absent any description in your question of the disparity!), I'd say either:

  1. you're using some table feature we don't support yet, or

  2. if the document is 30 pages long, or its document.xml longer than 300KB, the faster 'non XSLT' code will be used. This code doesn't have feature parity yet.

2019 Update

For some context, there are 2 main ways to do docx to PDF in the docx4j world:

  • older/cheerful approach: using docx4j-export-fo (which is the XSL FO approach discussed here, and which that tables sample document is for)
  • the commercial PDF Converter, which offers higher quality and performance (at a price), and has much better table support

docx4j will automatically use export-fo if the jar is on your classpath.

If you want to try the commercial PDF Converter, you need to point to an instance using https://github.com/plutext/docx4j/blob/master/src/samples/_resources/docx4j.properties#L90



来源:https://stackoverflow.com/questions/20437235/doc4j-having-issues-converting-docx-to-pdf-with-tables-in-the-document

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!