我正在使用 Prawn PDF 库在我的 Rails 应用程序中生成 PDF。一切正常,但在 Acrobat 或 Acrobat Reader 中打开生成的 PDF 时,显示以下消息:
An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem.
Adobe 在其 Acrobat 8.1.3 发行说明中将此列为已修复。
1810668 Memory leak while printing large document with images: > When a large document is exported to a PostScript, or sent to a printer for printing "An error exists on this page. Acrobat may not display the page correctly. Please contact the person who created the PDF document to correct the problem" can occur. This problem was encountered on certain documents with a large number of monochrome images, but has been rectified in 8.1.3.Root: Fixes issue found in 8.1.2.
但我在所有当前版本的 Acrobat Professional 和 Acrobat reader 中都看到了这个问题。我的 PDF 确实在每一页上都使用了背景图像,有很多页面(通常超过 75 页),并且有很多透明图像,但没有任何东西会导致错误。此外,Mac 的预览显示没有问题,如果您在 Acrobat 错误上按“确定”,一切都很好。
我在 Acrobat Professional 中运行 Preflight 工具来检查 PDF 语法错误,没有发现任何错误,但有一些警告“Unbalanced q and Q operators”。
这是面向客户的应用程序,因此我无法更改设置来抑制 PDF 阅读器中的错误。
关于如何让错误消失的任何想法?
最佳答案
正如 Mark 指出的那样,“q”和“Q”运算符必须在 pdf 文件中保持平衡。
Prawn 的PDF库好像有bug。我在一个未解决问题的评论中发现了这一点:
I made an workaround some weeks ago by patching the prawn-library itself. The root of this error is an "unbalanced q/Q", which appears only in Adobe Acrobat Pro preflight. I patched it by adding an additional \q in the prawn PDF-Generator.
关于ruby-on-rails - Prawn 生成文档出现 "error exists on this page"PDF错误如何解决?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5463172/