Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wicked_pdf: footer height/styling

I'm using the awesome wicked_pdf gem to generate a PDF, but I can't figure out how to change certain styles within the footer.

I'm having a HAML template for the footer looking roughly like this:

!!!
%html
  %head
    %meta{:charset => "utf-8"}
    = wicked_pdf_stylesheet_link_tag "pdf"

  %body
    .footer
      %p Line 1
      %p Line 2
      %p Line 3

And some styles:

.footer {
  padding-top: 1em;
  border-top: 1px solid #ccc;
}

The styles are applied just fine, but the due to a small height of the footer, only the first line is visible. I've tried to set the height via CSS, but no dice so far. If I set a footer using e.g the center, attributes or right supplying text directly, line breaks cause the footer to "grow" as expected.

Any idea on how to modify the footer height?

like image 957
polarblau Avatar asked Oct 02 '11 14:10

polarblau


1 Answers

You'll have to adjust the bottom margin of the PDF to make room for the footer if it is over a certain size.

respond_to do |format|
  format.pdf do
    render :pdf => 'some_pdf',
           :margin => { :bottom => 30 },
           :footer => { :html => { :template => 'pdfs/footer.pdf.erb' } }
  end
end

or you can throw that margin value in your config/initializers/wicked_pdf.rb file if it is a site-wide thing.

like image 91
Unixmonkey Avatar answered Oct 14 '22 05:10

Unixmonkey