7

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?

polarblau
  • 17,649
  • 7
  • 63
  • 84

1 Answers1

21

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.

Unixmonkey
  • 18,485
  • 7
  • 55
  • 78
  • Thanks! Makes sense. Can I define anything in the initializer? And will settings made in controllers/mailers override these defaults? Would you have some documentation on this anywhere? Cheers! – polarblau Oct 03 '11 at 20:35
  • Yes. Options defined in the initializer are site-wide, but you can override any of them in the render :pdf call. Options are documented here: https://github.com/mileszs/wicked_pdf – Unixmonkey Oct 04 '11 at 14:24