2012-06-25 124 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. 

跨度應該能夠包含所需的筆劃。 希望這有助於。