You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Dismiss the error, and notice that the footer only shows up on the 1st page.
Root Cause
Looks like the error.pdf is missing a /DeviceRGB cs, but I'll leave that decision for the PDF experts.
Sample Code
The following code generates a pdf with the error, plus variants to demonstrate the "edges" of the issue.
require"prawn"LOREM="Lorem ipsum dolor sit amet, consectetur adipiscing elit."defcreate_pdf(name,options={})Prawn::Document.generate(name)do |pdf|
# Default optionsline_count=options[:line_count] || 12page_count=options[:page_count] || 2dynamic= !(options[:static] || false)fill_color=options[:fill_color] || '000000'pdf.fill_colorfill_colorunlessfill_color.empty?pdf.repeat(:all,:dynamic=>dynamic)dopdf.move_cursor_to60pdf.text"FOOTER TEXT"pdf.text"PAGE ##{pdf.page_number.to_s}"endpdf.move_cursor_topdf.bounds.topline_count.times{ |i| pdf.text(LOREM,size: 13)}(page_count - 1).timesdopdf.start_new_pageline_count.times{ |i| pdf.text(LOREM,size: 13)}endendend# Causes an error when the 2nd page is scrolled into view (Adobe Acrobat Reader)create_pdf('error.pdf')# No error here, but the footer ONLY shows on the 1st pagecreate_pdf('fewer_lines.pdf',page_count: 40,line_count: 10)# Footer shows up, but page number is wrong after 1st page (obviously)create_pdf('static_footer.pdf',static: true)# Totally works, but text is now red ;)create_pdf('red.pdf',fill_color: 'AA0000')# Hacky work-aroundcreate_pdf('slightly_darker_black.pdf',fill_color: '000001')# Or if just avoid setting the fill_color, that works toocreate_pdf('no_fill.pdf',fill_color: '')
As previously stated, the problem is that certain call sequences can result in the color space not being set for a page. I want to mention that a quick workaround for the sample code above is to explicitly update the colors after a new page is started.
pdf.start_new_pagepdf.send:update_colors
I mentioned that only to show that it confirms where the missing directives are.
Problem
Here's the perfect storm:
dynamic: true
fill_color
set to'000000'
Steps to Reproduce
...and you'll get this error:
Dismiss the error, and notice that the footer only shows up on the 1st page.
Root Cause
Looks like the
error.pdf
is missing a/DeviceRGB cs
, but I'll leave that decision for the PDF experts.Sample Code
The following code generates a pdf with the error, plus variants to demonstrate the "edges" of the issue.
Similar / Related Issues
The text was updated successfully, but these errors were encountered: