开发者

How to fix "error exists on this page" PDF error from prawn generated documents?

I'm generating PDFs in my Rails application using the Prawn PDF library. Everything is working great, but when opening the resulting PDF in Acrobat or Acrobat Reader the message below is shown:

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 lists this as being fixed in their Acrobat 8.1.3 release notes.

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.

But I'm seeing the issue in all current Versions of Acrobat Professional and Acrobat reader. My PDF does use a background image on every page, has lots of pages (usually 75+), and has lots of transparent images, but nothing that should be causing an error. Additionally Mac's Preview shows no issues, and if you press "OK" on the Acrobat error, everything is fine.

I ran the Preflight tool in Acrobat Professional to check for PDF syntax errors and found no errors but some warnings "Unbalanced q and Q operators".

This is for a customer facing application so I can't change settings to suppress the error in the PDF reader.

Any ideas on how I can get the error to go away?


As Mark noted "q" and "Q" operators must be balanced in a pdf file.

Prawn PDF library seems to have a bug. I found this in a comment of an open issue:

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.

https://github.com/sandal/prawn-layout/issues#issue/25


This was a bug in prawn, it should be fixed in the 0.11.1 release.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜