Rails PDF Price List Headers and Footers

Is there a simpler code for setting headers and footers on all N pages in a PDF file that is created by the PRAWN plugin.

codes must be written to

" report.pdf.prawn ", which is the direct encoding area of ​​the PDF viewing page

Below are the codes in the report.pdf.prawn file

 pdf.text "Creation Date " + Time.now.strftime('%d-%m-%Y') pdf.text "Page Count:#{pdf.page_count}" 

All I want is to place these values ​​in the headers and / or footers left and right.

Any suggestion would be helpful.

+7
ruby-on-rails
source share
1 answer

Thank you so much for your concern. I got Wat I want from the link. This is what I did to get it working.

 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 
+4
source share

All Articles