Shrimp: floating text automatically to a new page

I have a simple code to create pdf.

def employe_details y = cursor bounding_box([0, y], :width => 16.cm) do @employe.each do |pr| txt = pr.week.to_s + ' ' txt += "work hours" text_box txt, size: 11, :at => [0.5.cm, cursor] move_down 0.4.cm end .#more similar texts . . end 

The problem is that this does not automatically create a new page. When the text exceeds the first page, the rest of the text is not displayed at all or these texts are not displayed on the new page.

How to automatically float texts to a new page when it reaches the end of the page?

Update: The problem with my code seems to be with this line :at => [0.5.cm, cursor] , if I delete the position, then it flows to the next page, the same thing happens when I use span. If I use a position with text in a range, then it does not flow to the next page, and if I delete it, it will go to the next page. So how can I use something like this

 text_box txt, size: 11, :at => [0.5.cm] text txt, size: 11, :at => [0.5.cm] 

Text field or text without cursor positions, I need to use x-position, because each line has different x-positions.

+1
source share
1 answer

bounding_box content will not flow to the next page. Instead, you can use span : (italicized)

Span is a special-purpose bounding box that allows you to position a column of elements relative to the margin_box field.

This method is typically used to stream a column of text from one page to the next .

manual mentions this on page 35:

This example also displays text passing through pages around the edge of a field and other bounding fields.

 # ... move_cursor_to 200 span(350, :position => :center) do text "Span is a different kind of bounding box as it lets the text " + "flow gracefully onto the next page. It doesn't matter if the text " + "started on the middle of the previous page, when it flows to the " + "next page it will start at the beginning." + " _ " * 500 + "I told you it would start on the beginning of this page." end 

The result is shown on pages 37/38:

Screenshot

+2
source

All Articles