wicked_pdf:页脚高度/样式 [英] wicked_pdf: footer height/styling

查看:127
本文介绍了wicked_pdf:页脚高度/样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用很棒的 wicked_pdf宝石来生成PDF,但我不知道如何在页脚内更改某些样式.

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.

我正在为页脚提供一个HAML模板,大致如下所示:

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

和一些样式:

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

应用样式还可以,但是由于页脚的高度很小,因此只有第一行可见.我试图通过CSS设置高度,但是到目前为止还没有骰子.如果我使用例如直接提供文本的centerattributesright设置页脚,则换行会导致页脚按预期增长".

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?

推荐答案

如果页脚超过一定大小,则必须调整PDF的底部边距以为页脚腾出空间.

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

或者,如果是站点范围的内容,则可以将该边距值扔到config/initializers/wicked_pdf.rb文件中.

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

这篇关于wicked_pdf:页脚高度/样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆