开发者

How can I span tabular content across two pages using Prawn?

I have tabular content, basically one big table, that needs to span across both pages of an open book. So imagine that a book or catalog is open in front of you. Every time you turn a page, you will see a new table that spans across both facing pages.

I know that Prawn can do automatic pagination, but is there a way to make sure a table stays together across pages? In other words, if some text wrapping in a table cell on the开发者_如何学JAVA lefthand side causes a row to be enlarged, the corresponding row on the next page needs to reflect the new size.

Can this be done?


if I need the same demands, I will do something like the following, please tell for any clarification:

require 'Prawn'
Prawn::Document.generate("hello.pdf") do
  table_width = 500
  separator = 100
  0.upto(1) do |i|
    start_new_page
    x = -i * (table_width + separator / 2)
    y = 0
    translate(x, y) do
      table([[
        make_cell(:content => "111111111111111", :width => table_width, :border_width => 1),
        make_cell(:content => "", :width => separator, :border_width => 0),
        make_cell(:content => "222222222222222", :width => table_width, :border_width => 1)
        ]], :width => table_width*2+separator)
      end
    end
  end

and the output should look like the following...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜