目标是:创建具有标题横幅和重复标题表
的 PDF 问题是:如果表格开始新页面,pdf.move_down 不起作用
CODE:
# repeat drawing in every page
pdf.repeat(:all, :dynamic => true) do
pdf.font("#{Rails.root}/vendor/pdffonts/ThonburiBold.ttf") do
pdf.font_size = 8
pdf.float { pdf.text "Time: #{tt}", :align => :left }
pdf.float { pdf.text "Page #{pdf.page_number}", :align => :right }
pdf.float { pdf.text "Inquiry Name: #{page_title}", :align => :center }
pdf.move_down 15
pdf.float { pdf.text "AS OF #{Time.now.to_date}", :align => :center }
pdf.move_down 40 ## move down to draw the following table
pdf.stroke_horizontal_rule
end
## ... building big_data_array for table ...
table_config = {
:header => true,
:row_colors => ["FFFFFF", "F0F0F0"],
:cell_style => { :padding => 1 }
}
# draw a long table
pdf.table(big_data_array, table_config) do |t|
t.before_rendering_page do |c|
pdf.move_down 40 ## try to add margin-top before render the table in every page
end
t.row(0).background_color = "DADADA"
# style rows and cells ...
end