是否有更简单的代码来设置 PRAWN Plugin 生成的 PDF 文件中所有 N 页上的页眉和页脚。
代码将被写成
“ report.pdf.prawn ”文件,是PDF查看页面的直接编码区
以下是文件report.pdf.prawn
中的代码
pdf.text "Creation Date " + Time.now.strftime('%d-%m-%Y')
pdf.text "Page Count:#{pdf.page_count}"
我想要的只是将这些值定位到页眉或/和页脚的左右两侧。
任何建议都会有所帮助。
最佳答案
非常感谢您的关心。我从链接中得到了我想要的
这就是我为使其工作所做的工作..
creation_date = Time.now.strftime('%d-%m-%Y')
page_count=pdf.page_count
powered_by = @companylogo
# will get @companylogo from the controller
Prawn::Document.generate("show_sd_report_pdf.pdf", :skip_page_creation => true) do
pdf.page_count.times do |i|
pdf.go_to_page(i+1)
pdf.draw_text "Creation Date : " + creation_date, :at=>[590,530]
pdf.draw_text "Page Count : #{i+1} / #{pdf.page_count}", :at=>[1,1]
pdf.draw_text "Powered by : ", :at=>[590,1]
pdf.image powered_by, :width => 25, :at=>[670,15]
end
end
**or insted of draw_text**
pdf.bounding_box([1,540], :width => 300, :height => 300) do
pdf.text "Username : " + user_name
end
关于ruby-on-rails - Rails PDF 大虾页眉和页脚,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3404315/