2012-06-25 68 views
3

我正在尝试使用对象0.12.0生成pdf。对虾pdf和分页符

我呈现的内容非常动态,通常跨越多个页面。

我遇到的问题是,当它自动启动一个新页面时,当前边界框会“断开”。 在新页面上呈现的文本没有正确的边界框。 如果我使用stroke_bounds,我可以在页面底部看到底部笔划。 我已经在各种论坛上阅读过这个问题,但似乎无法弄清楚实际发生了什么。

这里是一个循环出来的内容具体代码:

items.each do |item| 
    group do 
    title_text = [{ text: item.title, styles: [@heading_style], size: 11}] 
    formatted_text title_text 
    text(item.description, size: 9) 
    stroke { line(bounds.bottom_left, bounds.bottom_right); } 
    end 
end 

如你本身我想提请只是每个项目下面一条线,这就是为什么我需要的电流边框是正确的。

+0

遇到同样的问题。你能找到什么吗? – pduersteler

回答

2

每大虾文档: http://prawnpdf.org/manual.pdf

边界框被绑定到页面边距:

A bounding box is a structure which provides boundaries for inserting content. A bounding box 
also has the property of relocating the origin to its relative bottom-left corner. However, be aware 
that the location specified when creating a bounding box is its top-left corner, not bottom-left 
(hence the [100, 300] coordinates below). 

一个跨度为界,将跨页正常流动型较好的选择:

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. 

跨度应该能够包含所需的笔划。 希望这有助于。