Is there any wkhtmltopdf option to convert html text rather than file?

后端 未结 5 808
栀梦
栀梦 2021-02-19 09:47

I recently stumbled on wkhtmltopdf and have found it to be an excellent tool for on-the-fly conversion from html to pdf in the browser.

A typical usage (in Windows) woul

5条回答
  •  执笔经年
    2021-02-19 10:19

    You can pipe content into wkhtmltopdf using the command line. For Windows, try this:

    echo "

    blep

    " | wkhtmltopdf.exe - test.pdf

    This reads like "echo

    blep

    , output it's stdout (standard out stream) to wkhtmltopdf stdin (standard in stream)".

    The dash - in the wkhtmltopdf command means that it takes it's input from stdin and not a file.

    You could also echo HTML into a file, feed that file to wkhtmltopdf and delete that file inside a script.

提交回复
热议问题