我想用ruby和虾(0.8.4)宝石生成一个pdf。 pdf的第一页应该具有与以下页面不同的页眉/页脚。数据将显示在表格中,但表格显示在多个页面上。
示例:
答案 0 :(得分:0)
解决。
require "rubygems"
require "prawn"
require "prawn/core"
require "prawn/layout"
require "prawn/measurement_extensions"
Prawn::Document.generate("test.pdf", :page_size => "A3", :page_layout => :landscape, :margin => 0) do
padded_box 30.mm do
move_down(40.mm)
items = 100.times.map {|i| [i, i]}
table items, :border_style => :underline_header, :headers => ["Column#1", "Column#2"]
end
page_count.times do |i|
page_num = i+1
go_to_page(page_num)
if page_num == 1
# header of first page
text_box "header#1", :at => [30.mm, 290.mm], :size => 18
image "logo.png", :at => [12.mm,(297-15.78).mm]
else
# header 2..n
text_box "header#2..n", :at => [30.mm, 290.mm], :size => 12
end
end
end