【问题标题】:Add margin to PDF footer when using wkhtmltopdf使用 wkhtmltopdf 时为 PDF 页脚添加边距
【发布时间】:2013-02-28 05:45:30
【问题描述】:

我正在使用wkhtmltopdf 在文件系统上创建 pdf 文档。 当我插入这样的参数时,PDF 生成良好:

psi.Arguments = "- --footer-html "http://localhost/pdf/footerpage.html" --footer-right "Page [page] of [toPage]" "C:\PDF\pdf.pdf""

问题在于页脚包含不适合的图像。当我尝试像这样在底部添加边距时:

psi.Arguments = "- --margin-bottom 30 --footer-html "http://localhost/pdf/footerpage.html" --footer-right "Page [page] of [toPage]" "C:\PDF\pdf.pdf""

pdf 无法生成。错误:“--margin-bottom 指定的位置不正确” 我在 wiki https://code.google.com/p/wkhtmltopdf/issues/detail?id=957 上找到了这个,但没有帮助。

有什么想法吗?

谢谢

【问题讨论】:

  • 您是否在转义传递的参数中的引号?还是从您的代码中复制的?
  • 是的,我在我的代码中使用了转义

标签: c# command-line-arguments wkhtmltopdf ashx


【解决方案1】:

评论太大了,所以发布这个作为答案。

我的实验表明wkhtmltopdf 对指定参数的顺序很特别。 this answer 中也提到了这一点。

听起来很奇怪,我很确定我做错了什么。

你可以试试这个 -

psi.Arguments = "- --footer-html \"http://localhost/pdf/footerpage.html\" --footer-right \"Page [page] of [toPage]\" --margin-bottom 30 \"C:\PDF\pdf.pdf\""

【讨论】:

  • 更改参数顺序时不走运
猜你喜欢
  • 2014-11-30
  • 2018-02-11
  • 1970-01-01
  • 1970-01-01
  • 2014-10-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多