ruby-on-rails-3 - wicked_pdf 和 wkhtmltopdf 页面大小问题

标签 ruby-on-rails-3 ruby-on-rails-plugins wkhtmltopdf

我使用了这些设置

WickedPdf::config = {
    :layout           => 'application.pdf.html', # use 'pdf.html' for a pfd.html.erb file
    :wkhtmltopdf      => '/bin/wkhtmltopdf', # path to binary
    :orientation      => 'Portrait', # default , Landscape
    :page_size        => 'A4',
    :dpi              => '300',
    :print_media_type => true,
    :no_background    => true,
    :margin           => {:top    => 0, # default 10 (mm)
                          :bottom => 0,
                          :left   => 0,
                          :right  => 0},

}

并将体型设置为
body {
    margin: 0;
    padding: 0;
    background-color: #FFF;
    width: 210mm;
    height: 297mm;
}

和一个 .page 类的 div
.page {
    display: inline-block;
    clear: both;
    border: 2px solid #FF0000;
    width: 210mm;
    height: 297mm;
    page-break-after: auto;
}

但是当创建 pdf 时,.page div 几乎是 pdf 页面的一半。

最佳答案

如果您正在 float 页面容器,则它将不起作用。我遇到了完全相同的问题,一旦我删除了 float 专业版。

所以你的页面容器应该是:

.page {
display: block;
clear: both;
border: 2px solid #FF0000;
page-break-after: auto;}

因为inline-block就像漂浮它离开了。

关于ruby-on-rails-3 - wicked_pdf 和 wkhtmltopdf 页面大小问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5701186/

相关文章:

ruby-on-rails - 如何增加 Heroku 日志流失详细程度以包含所有 Rails 应用程序详细信息?

ruby-on-rails - 插件中的生成器和迁移 (rails 3)

php - wkhtmltopdf 为每个创建的 pdf 写入 apache 错误日志

c# - 如何在Azure函数生成的PDF中显示文本

ruby-on-rails - 创建 has_many :through records 时跳过验证

ruby-on-rails-3 - 在 Rails 应用程序中使用什么来上传不同的文件格式(音频、视频)?

ruby-on-rails - 是否可以将 best_in_place 与 twitter bootstrap 中的 typeahead 一起使用?

ruby-on-rails - 最佳实践 : Multiple categories - best plugin for it (acts as taggable, 充当树,...)

asp.net-mvc-4 - 在mvc 4中使用wkhtmltopdf将Html中的图像转换为PDF

ruby-on-rails - 从 Heroku 共享数据库迁移到 Heroku Postgres; Heroku Postgres 计划选择