Hi Everyone,
I am using Prawn PDF to create PDF files on the fly in my Rails application.
I recently came across the rails cell.blank?
function, which has proved to be really handy, I can hide any <li>
rows I want if there is nothing to display - something I have been wondering about for a while!
Is it possible to do the same in Prawn? Hide a line if it's empty?
At the moment if I have the following:
Contact Name
Address Line 1
Address Line 2
Address Line 3
Postcode
Phone Number
Fax Number
If, for example, the user only entered the contact name and postcode there would be a significant gap where the Address Line's 1, 2 and 3 should be.
If I could ignore those rows because they are empty and display it as:
Contact Name
Postcode
it would tidy up my PDF and save the user having to use the incorrect field to ensure the address looks right in the PDF.
This is what my Prawn code looks like:
pdf.text_box "Client", :size => 9, :at => [50,673]
pdf.text_box "#{@kase.company.companyname}", :size => 9, :at => [100,673]
pdf.text_box "#{@kase.company.companyaddressline1}", :size => 9, :at => [100,665]
pdf.text_box "#{@kase.company.companyaddressline2}", :size => 9, :at => [100,655]
pdf.text_box "#{@kase.company.companyaddressline3}", :size => 9, :at => [100,645]
pdf.text_box "#{@kase.company.companyaddresscity}", :size => 9, :at => [100,635]
pdf.text_box "#{@kase.company.companyaddresspostcode}", :size => 9, :at => [100,625]
I have searched the Prawn google user group site but can't seem to find what I need.
Thanks in advance!
Danny