asdfkjasdfjk
asdfkjasdfjk

Reputation: 3904

Prawn bounding box stroke with auto height

bounding_box([(bounds.left + 5), bounds.top - 130], width: 750) do
  font_size(10)
  text_box "#{@post.description}", inline_format: :true, :at => [bounds.left + 10, bounds.top - 10]

  stroke do
    rectangle [0, 0],  760, :height => :auto  # ===> I need this height auto
  end
end

I am using prawn to generate pdf in my rails app. Above is my code. I need to show the description in a rectangle. When the description is very large, it goes out of the rectangle. Rectangle height do not automatically increase. How can I do that? Also how to add page automatically when description do not fit in single page?

Upvotes: 1

Views: 2280

Answers (1)

sockmonk
sockmonk

Reputation: 4255

After your text_box, replace the stroke block with this:

stroke_bounds

That will draw a rectangle around the bounding box, however tall it is, as long as it doesn't cross a page boundary.

Upvotes: 1

Related Questions