Guest User

Untitled

a guest
Jul 18th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. ## Works
  2. require 'prawn'
  3. Prawn::Document.generate 'test.pdf' do |p|
  4. p.bounding_box([0, 280], :width => 550, :height => 26) do
  5. p.stroke_bounds
  6. p.bounding_box([5, p.bounds.top], :width => 150, :height => 25) do
  7. p.text_box("Some Text1", :width => 150, :height => 15, :padding => 2)
  8. p.stroke_rectangle(p.bounds.top_left, 150, 15)
  9. end
  10. p.bounding_box([165, p.bounds.top], :width => 150, :height => 25) do
  11. p.text_box("Some Text2", :width => 150, :height => 15, :padding => 2)
  12. p.stroke_rectangle(p.bounds.top_left, 150, 15)
  13. end
  14. p.bounding_box([335, p.bounds.top], :width => 150, :height => 25) do
  15. p.text_box("Some Text3", :width => 150, :height => 15, :padding => 2)
  16. p.stroke_rectangle(p.bounds.top_left, 150, 15)
  17. end
  18. end
  19. end
  20. #In this version, the unlabeled boxes line up side by side, as required.
  21.  
  22. ## Doesn't work
  23.  
  24. require 'prawn'
  25. Prawn::Document.generate 'test.pdf' do |p|
  26. p.bounding_box([0, 280], :width => 550, :height => 26) do
  27. p.stroke_bounds
  28. p.bounding_box([5, p.bounds.top], :width => 150, :height => 25) do
  29. p.text_box("Some Text1", :width => 150, :height => 15, :padding => 2)
  30. p.stroke_rectangle(p.bounds.top_left, 150, 15)
  31. p.text("small label text1")
  32. end
  33. p.bounding_box([165, p.bounds.top], :width => 150, :height => 25) do
  34. p.text_box("Some Text2", :width => 150, :height => 15, :padding => 2)
  35. p.stroke_rectangle(p.bounds.top_left, 150, 15)
  36. p.text("small label text2")
  37. end
  38. p.bounding_box([335, p.bounds.top], :width => 150, :height => 25) do
  39. p.text_box("Some Text3", :width => 150, :height => 15, :padding => 2)
  40. p.stroke_rectangle(p.bounds.top_left, 150, 15)
  41. p.text("small label text3")
  42. end
  43. end
  44. end
  45. #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