wicked_pdf: footer height/styling

半世苍凉 提交于 2019-12-19 02:04:14

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/7627012/wicked-pdf-footer-height-styling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!