Created
May 12, 2014 20:00
-
-
Save TylerRick/9819204441df2c8703b5 to your computer and use it in GitHub Desktop.
Indent doesn't get reset after rendering a centered table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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