views:

67

answers:

3

Is there a simpler code to set the Headers and Footers on all N pages in a PDF file that is generated by PRAWN Plugin.

the codes are to be written in a

"report.pdf.prawn" file, which is a direct coding area of the PDF view page

The below are the codes in the file report.pdf.prawn

pdf.text "Creation Date " + Time.now.strftime('%d-%m-%Y')

pdf.text "Page Count:#{pdf.page_count}"

All i want is to position tes values to header's or/and footers left and right side. Any suggestion would be helpful. Thanks

A: 

Have you seen the tips on this question? They may do what you're asking it sounds like: http://stackoverflow.com/questions/2695019/header-and-footer-in-prawn-pdf

jasonpgignac
A: 

Thank you so much for your concern.I got wat i want from the link This is what i did to make it work..

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

A: 

but the

Prawn::Document.generate("show_sd_report_pdf.pdf", :skip_page_creation => true) do

comes under all the codings of the report.pdf.prawn file which makes it diffrent section in the same pdf file.

BUT it worked for me, am getting wat excately is needed, just some code reductions needed !

Thanks again,