wkhtmltopdf: Is it possible to merge PDF files?

∥☆過路亽.° 提交于 2019-12-03 17:11:04

问题


Using this library wkhtmltopdf, is it possible to merge 2 pdf files. I need to generate a report and merge the report with some attached documents.

Generation of report is done, converting from HTML to PDF. But I need to merge the resulting PDF with some other PDFs


回答1:


wkhtmltopdf doesn't provide support for merging PDF's. You can accomplish this using GhostScript. It's a pretty powerful tool and frequently used by Linux users.

You can use the following command:

gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=out.pdf in1.pdf in2.pdf

You can try these links for further reading:

  • GhostScript
  • Merge PDF's using Ghostscript (Windows)

In case you want it for Linux refer

  • Merge PDF's using Ghostscript (Linux)

EDIT: As stated by @nenotelp there are other tools available as well. The part that @nentelp mentioned is regarding the handling of bookmarks which is better with iText or iTextSharp. If this is your requirement you can certainly opt for other tools.

P.S. - Google Ghostscript. You will find tons of references.




回答2:


You can combine multiple html files to one output pdf file with this library. For e.g if u have:

my-html-file-nr-1.html
my-html-file-nr-2.html
....
my-html-file-nr-n.html

You can simply:

wkhtmltopdf my-html-file-nr-* output.pdf


来源:https://stackoverflow.com/questions/18736580/wkhtmltopdf-is-it-possible-to-merge-pdf-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!