Skip to content

Instantly share code, notes, and snippets.

@TylerRick
Created May 12, 2014 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TylerRick/9819204441df2c8703b5 to your computer and use it in GitHub Desktop.
Save TylerRick/9819204441df2c8703b5 to your computer and use it in GitHub Desktop.
Indent doesn't get reset after rendering a centered table
require "prawn"
Prawn::Document.generate("#{__FILE__}.pdf") do |pdf|
pdf.start_new_page margin: [100, 100, 100, 100]
pdf.stroke_axis
orig_bounds_width = pdf.bounds.width
pdf.formatted_text_box [ { :text => "width: #{pdf.bounds.width}" } ], :at => [0, 20]
pdf.indent(100) do
pdf.stroke_axis
pdf.formatted_text_box [ { :text => "width: #{pdf.bounds.width}" } ], :at => [0, 20]
# Problem only occurs when table too big to fit on one page, and position: :center is used
pdf.table([ ['Test'] ]*30, {position: :center})
end
pdf.start_new_page margin: [100, 100, 100, 100]
pdf.stroke_axis
# Observe: Width is 312.0, but should have been reset to 412.0
pdf.formatted_text_box [ { :text => "width: #{pdf.bounds.width} (should still be #{orig_bounds_width})" } ], :at => [0, 20]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment