prawn-layout
prawn-layout copied to clipboard
Adobe Reader 9.x Display Error if using table
Hi,
if I create a document with table I get an error with the Acrobat Reader 9.x
"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."
The error occurs only if I use more then six columns in my table.
For example following code works fine without errors:
Prawn::Document.generate("test.pdf", :page_size => "A4",
:page_layout => :landscape) do |pdf|
data = [['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow']]
pdf.table data
end
If I add some columns I get the display error. Following code reproduce it.
Prawn::Document.generate("test.pdf", :page_size => "A4",
:page_layout => :landscape) do |pdf|
data = [['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow', 'Gregory Brow','Gregory Brow'],
['Gregory Brown', 'Gregory Brow', 'Gregory Brow', 'Gregory Brow','Gregory Brow','Gregory Brow','Gregory Brow']]
pdf.table data
end
The error only appear on the Acrobat Reader 9.x.
Mac Preview and Foxit Reader are working without errors.
I receive erros which go away if I remove tables, but reducing rows doesn't seem to help. This is in IETester on 7 and 8 with reader 9 installed.
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.
Thanks, Larry!
Hey! We're having the same issue here but can't figure out how to apply your fix. Could you please submit a patch/commit?
Thank you.
Hey jbpros! I fixed this issue in a "quick and dirty" way by patching the /Library/Ruby/Gems/1.8/gems/prawn-core-0.8.4/lib/prawn/document/graphics_state.rb file. Modify:
def save_graphics_state
add_content "q"
if block_given?
yield
restore_graphics_state
end
end
to
def save_graphics_state
add_content "q"
add_content "q"
if block_given?
yield
restore_graphics_state
end
end
and the error disappeared. I know it isn't a good solution but it works for me. The path above works on MacOSX. You have to find out your path depending from your OS/Linux Distribution.
Thank you for your quick answer. Let's try that!
Has this been fixed in the latest version?
Thanks!!! for your patch :) It also works for me