Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Works
- require 'prawn'
- Prawn::Document.generate 'test.pdf' do |p|
- p.bounding_box([0, 280], :width => 550, :height => 26) do
- p.stroke_bounds
- p.bounding_box([5, p.bounds.top], :width => 150, :height => 25) do
- p.text_box("Some Text1", :width => 150, :height => 15, :padding => 2)
- p.stroke_rectangle(p.bounds.top_left, 150, 15)
- end
- p.bounding_box([165, p.bounds.top], :width => 150, :height => 25) do
- p.text_box("Some Text2", :width => 150, :height => 15, :padding => 2)
- p.stroke_rectangle(p.bounds.top_left, 150, 15)
- end
- p.bounding_box([335, p.bounds.top], :width => 150, :height => 25) do
- p.text_box("Some Text3", :width => 150, :height => 15, :padding => 2)
- p.stroke_rectangle(p.bounds.top_left, 150, 15)
- end
- end
- end
- #In this version, the unlabeled boxes line up side by side, as required.
- ## Doesn't work
- require 'prawn'
- Prawn::Document.generate 'test.pdf' do |p|
- p.bounding_box([0, 280], :width => 550, :height => 26) do
- p.stroke_bounds
- p.bounding_box([5, p.bounds.top], :width => 150, :height => 25) do
- p.text_box("Some Text1", :width => 150, :height => 15, :padding => 2)
- p.stroke_rectangle(p.bounds.top_left, 150, 15)
- p.text("small label text1")
- end
- p.bounding_box([165, p.bounds.top], :width => 150, :height => 25) do
- p.text_box("Some Text2", :width => 150, :height => 15, :padding => 2)
- p.stroke_rectangle(p.bounds.top_left, 150, 15)
- p.text("small label text2")
- end
- p.bounding_box([335, p.bounds.top], :width => 150, :height => 25) do
- p.text_box("Some Text3", :width => 150, :height => 15, :padding => 2)
- p.stroke_rectangle(p.bounds.top_left, 150, 15)
- p.text("small label text3")
- end
- end
- end
- #In this second case, all three labeled form items will come out looking fantastic, but on three separate pages.
Add Comment
Please, Sign In to add comment