Doc4j-在使用文档中的表格将docx转换为PDF时遇到问题 [英] Doc4j - Having issues converting docx to PDF with tables in the document

查看:972
本文介绍了Doc4j-在使用文档中的表格将docx转换为PDF时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚尝试通过 docx4j 的示例Web应用程序访问docx文档,网址为: http://webapp.docx4java.org/OnlineDemo/docx_to_pdf_fop.html 生成的PDF文件具有表格格式错误.实际上,桌子的位置明显偏远...

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...

我只是想知道这是因为docx4j无法正确支持表还是某种错误.如果是这样,是否有人可以向我指出适当的信息.

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.

推荐答案

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

在没有看到您的docx的情况下(并且您对视差的问题没有任何描述!),我要么说:

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

  1. 您正在使用某些尚不支持的表格功能,或者

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

如果文档长30页,或者其document.xml长于300KB,则将使用速度更快的非XSLT"代码.该代码还没有功能奇偶校验.

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更新

在某些情况下,在docx4j世界中有两种将docx转换为PDF的主要方法:

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

  • 旧的/欢快的方法:使用docx4j-export-fo(这是这里讨论的XSL FO方法,该表示例文档适用于该方法)
  • 商业PDF转换器,具有更高的质量和性能(价格),并且具有更好的表格支持

docx4j将自动使用export-fo.

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

如果要尝试使用商用PDF Converter,则需要使用

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

这篇关于Doc4j-在使用文档中的表格将docx转换为PDF时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆