我正在生成一个带有Prawn的PDF,它在第一页上有一个页眉,一个重复的页脚和整个表格数据。
如果我添加没有边界框的表格,它在页眉之后开始,但它与页脚重叠。如果我将表格放在一个边界框中,它会避开页脚。但是为了避免页眉,我必须把它放在页眉下面,这样我就会在随后的每一页上丢失该空间。
有没有其他方法可以做到这一点?
发布于 2015-11-18 20:44:39
在对虾的github上找到了答案。它要求您将表格包装在一个边界框中,并手动设置边界框的起始位置,这只会影响第一页。
# ... draw your first-page header here
# Store away the y-position below the header on the first page
old_y = y
# Start a bounding box the size of the page (excluding the footer)
bounding_box([bounds.left, bounds.top],
:width => bounds.width, :height => bounds.height - FooterHeight) do
# Restore the old y-position for the first page
self.y = old_y
table(...)
end
https://stackoverflow.com/questions/33789047
复制