douhensheng1131 2013-09-06 12:08
浏览 90
已采纳

wkhtmltopdf扩大了服务器上的内容

I'm generating invoices based on an online office environment. On my local server (win7) everything is working as it should. PDF's are generated perfectly with correct measurements etc. but when generating a pdf via the online server (linux) all the content gets enlarged. The pdf's hold a header, invoice rules and a footer. All of those hold text and a background-image. This causes the content to go beyond the page dimensions.

Here's an image to illustrate what I mean, left the locally generated pdf and to the right the one generated online. (blanked out some fields) enter image description here

Thing's I've tried, but with no succes:

  • adding the zoom parameter
  • adding the dpi parameter
  • updating wkhtmltopdf on the server
  • setting max sizes in css (i.e. a4 size in mm)

Does anyone know how to make the PDF look the same on the online server? Is there an argument/parameter I'm missing?

Extra info:

  • I'm running v0.11.0 rc2 locally and the server is on v0.11.0 rc1. Coulnd't find the rc2 version for linux or mac.
  • I'm using the footer, header and zoom arguments when generating, nothing else.
  • 写回答

2条回答 默认 最新

  • douchen2011 2013-09-09 06:43
    关注

    My colleague fixed the problem this weekend. He updated wkhtmltopdf but that didnt help. Then he proceeded to set the max width in pixels and that did the trick. I already had set the max-width and height in mm but had no effect. This did make the header get positioned wrong, half way accros the page. The fix for this was adding height:0; to it. The fixes don't make that much sense to me but hey it works :P.

    I'm using the following params now:

    ["disable-smart-shrinking"],
    ["margin-left" => 0],
    ["margin-right" => 0],
    ["page-width" => "210mm"],
    ["page-height" => "297mm"],
    ["margin-bottom" => 0],
    ["header-html" => CUSTOM FUNCTION],
    ["margin-top" => "90mm"],
    ["header-spacing" => "90"],
    ["margin-bottom" => "18mm"],
    ["footer-html" => CUSTOM FUNCTION],
    ["javascript-delay" => 1000]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 前端echarts坐标轴问题
  • ¥15 CMFCPropertyPage
  • ¥15 ad5933的I2C
  • ¥15 请问RTX4060的笔记本电脑可以训练yolov5模型吗?
  • ¥15 数学建模求思路及代码
  • ¥50 silvaco GaN HEMT有栅极场板的击穿电压仿真问题
  • ¥15 谁会P4语言啊,我想请教一下
  • ¥15 这个怎么改成直流激励源给加热电阻提供5a电流呀
  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳