Prawn:自动将文本浮动到新页面

我有以下简单的代码来生成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 

问题是,这不会自动创建新页面。 当文本超出第一页时,文本的其余部分根本不显示,或者这些文本未显示在新页面中。

如何在文本到达页面末尾时自动将文本浮动到新页面?

更新:我的代码问题似乎与这一行:at => [0.5.cm, cursor] ,如果我删除位置然后它流向下一页,当我使用span时也会发生同样的情况。 如果我在span中使用带有文本的位置,那么它不会流到下一页,如果我将其删除,那么它将流向下一页。 那么我怎么能用这样的东西呢

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

没有光标位置的文本框或文本,我需要使用x位置,因为每一行都有不同的x位置。

bounding_box内容不会流入下一页。 您可以改为使用span :(强调添加)

span是一个特殊用途的边界框,允许一列元素相对于margin_box定位。

此方法通常用于将一列文本从一个页面流向下一个页面

手册在第35页提到了这一点:

此示例还显示了在边距框和其他边界框之后流过页面的文本。

 # ... 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 

结果显示在第37/38页:

截图