prawn-layout icon indicating copy to clipboard operation
prawn-layout copied to clipboard

Adobe Reader 9.x Display Error if using table

Open LarryG opened this issue 14 years ago • 8 comments

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.

LarryG avatar Apr 05 '10 11:04 LarryG

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.

djnawara avatar Jun 10 '10 15:06 djnawara

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.

LarryG avatar Jun 11 '10 07:06 LarryG

Thanks, Larry!

djnawara avatar Jun 11 '10 14:06 djnawara

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.

jbpros avatar Jul 16 '10 08:07 jbpros

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.

LarryG avatar Jul 16 '10 08:07 LarryG

Thank you for your quick answer. Let's try that!

jbpros avatar Jul 16 '10 08:07 jbpros

Has this been fixed in the latest version?

bjensen avatar Oct 07 '10 10:10 bjensen

Thanks!!! for your patch :) It also works for me

cis-pjain avatar Jun 21 '12 09:06 cis-pjain