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

后端 未结 5 807
栀梦
栀梦 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:03

    I couldn't get wkhtmltopdf to work on my end converting raw html to PDF, but I did find a simple microservice that was able to do it with a couple minutes work on bantam.io.

    Here's how it works:

    bantam
     .run('@images/html', {
       html: `
       

    TEST


    `, imageType: 'pdf', }) .then(pdfUrl => { // pdf is temporarily hosted on AWS S3 via a secure link at `pdfUrl` });

    They also have options for taking in a URL rather than raw HTML and you can produce images as well as PDFs. Here are the docs: https://bantam.io/functions/@images/html?link=docs&subLink=0

提交回复
热议问题