Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Issue with Full Template #364

poori opened this Issue · 10 comments

4 participants


Hi everyone!

Thanks for the awesome gem! I discovered what seems to be a bug and thought I would report it, along with steps to reproduce.

When I try to take a template and save it, it saves without issues but the document gives a "There was a problem reading this document (14)" when opening the document in acrobat reader. However, it is viewable in OSX's previewer. It seems very similar to issue #199.

Below are steps to reproduce:

download candidate pdf:

then run

Prawn::Document.generate("test.pdf", :template => "F00060.pdf") do
#do nothing

Then try to open test.pdf, and it gives the error above.

Prawn Version:
gem 'prawn', :git => "git://" (bundled today)

I also tried this on the file

filename = "#{Prawn::DATADIR}/pdfs/multipage_template.pdf"

from the manual example

and this seems to work fine. So it is possibly something that is only an issue with certain pdfs.

I tried going through the file to see differences but I just started learning the very basics of the pdf file format today and I am afraid it is beyond my ken.


A quick update. I took the same pdf file and did the following, which worked without any issues.

Prawn::Document.generate("/Users/myusername/Desktop/test.pdf", :skip_page_creation => true) do |pdf|

   (1..15).each do |n|
   #I just happened to know this pdf is 15 pages long...
   pdf.start_new_page(:template => filename, :template_page => n)                  

I'll second this, as I ran into it was well.

The workaround @poori posted can be improved with the advice given by @boazsegev in this thread, wherein he determines the number of pages to loop through rather than hardcoding it: #199

In fact, this issue appears to be a continuation of that one, except that it occurs when using as opposed to start_new_page(template)

Another example document you can use for this case is the Prawn manual itself.

I wonder how many people out there are generating documents with this method and are unaware that Adobe Reader users will choke on some of their PDFs.


Has anyone thought about the solution to this problem?

We just found that in our production environment, the workaround can consume over a hundred megabytes of memory for a single document. This is prohibitively expensive for scale.


Have you tried pointing to the github repo because this has been worked on recently and has been merged into master.

Please report here what you find. Thanks.


Hi Jon. Thanks so much for your work on this. Unfortunately, I am still seeing "There was a problem reading this document (14)" in Acrobat Reader for generated PDFs. Please let me know if there's anything else I can do to help.


Can you post the template that you are using and some sample code to try out?


Sure thing. Unfortunately, most of the documents I work with are proprietary. I used to be able to reproduce this with the Prawn manual itself, but that is now throwing a NilClass error.

I had a hard time finding a document outside my proprietary document store that failed using the gem as well as Prawn directly from the repo (kudos - many are fixed!). However, I did find one:

This is unopenable using Acrobat Reader after generating it like so: '/Users/jjordan/Dropbox/Rails_for_Designers_-_Slides.pdf').render_file('test.pdf')

@jonsgreen jonsgreen referenced this issue from a commit in jonsgreen/prawn
@jonsgreen jonsgreen Issue #364 Issue With Full Template
only set /Parent reference for page templates to appease Adobe Acrobat


I think I see what the problem is and it has to do with incorrect Parent references of object similar to #199; Adobe just doesn't like that. In fact it was my the fix for that issue that has resulted in this one for full templates.

Anyhow if you could try pointing your Gemfile to my fork: to see if my latest fix solves your problem that would be helpful. Thanks.


Jon, I tested this on a large set of documents that previously failed and am happy to report that they are all succeeding with your fix. Thanks again! Let me know if I can be of any assistance getting your work merged into prawn's master branch.

@jonsgreen jonsgreen referenced this issue from a commit in jonsgreen/prawn
@jonsgreen jonsgreen Issue #364 Issue With Full Template
only set /Parent reference for page templates to appease Adobe
correct nested_pages.pdf pages to point to correct parent for Adobe
reader and spec testing purposes
@practicingruby practicingruby added templates and removed stale labels
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.