【问题标题】:wkhtmltopdf: How to set a stretched A4 PDF document?wkhtmltopdf:如何设置拉伸的 A4 PDF 文档?
【发布时间】:2016-07-02 16:28:35
【问题描述】:

我有一个想要转换为 PDF 的页面,我希望它看起来像“Prince”那样,但使​​用的是 wkhtmltopdf。

如果你看这个例子:http://www.princexml.com/samples/invoice/invoicesample.pdf

并查看原始 HTML:http://www.princexml.com/samples/invoice/invoicesample.html

您可以看到 HTML 具有 100% 的宽度,但由于页面大小 (A4),它会缩小其宽度。

我一直在为“wkhtmltopdf”尝试很多选项,但没有得到任何好的结果!

这是属性列表:http://madalgo.au.dk/~jakobt/wkhtmltoxdoc/wkhtmltopdf_0.10.0_rc2-doc.html#Global%20Options

您能帮我找到正确的显示器吗?

这些是我尝试过很多方法的选项:

$options = array( 
    // 'page-width' => '216mm', 
    // 'page-height' => '279mm', 
    'page-size' => 'A4', 
    //'dpi' => 96, 
    //'image-quality' => 100, 
    //'disable-smart-shrinking', 
    //'no-outline', 
    'no-outline',           // option without argument
    'encoding' => 'UTF-8',  // option with argument
    'user-style-sheet' => $cssPath,
    'margin-top'    => 0,
    'margin-right'  => 0,
    'margin-bottom' => 0,
    'margin-left'   => 0,


    // 'orientation' => 'portrait', 
    // 'images' => true,
    // 'cookie' => array(),
    // 'dpi' => 300,
    // 'image-dpi' => 300
    // Default page options
    //'disable-smart-shrinking'
    );

左上角和右上角有边距,显示器有一个宽屏幕,100% 的元素不会变小。

【问题讨论】:

    标签: php pdf-generation wkhtmltopdf removing-whitespace


    【解决方案1】:

    enable/disable-smart-shrinking 选项将为您提供帮助。默认情况下,wkhtmltopdf 将内容缩放到配置的页面大小。您应该禁用此行为。

    【讨论】:

      猜你喜欢
      • 2021-10-16
      • 2013-12-25
      • 2011-01-23
      • 2012-09-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-03-05
      • 1970-01-01
      相关资源
      最近更新 更多