wkhtmltopdf as a service

 

POST https://api.pdfbroker.io/api/pdf/wkhtmltopdf

If you ever needed to create pdf documents from html in the past you probably at least tried the excellent tool wkhtmltopdf. Now, when many websites are moving to cloud based services it is not as easy to include this popular tool. Why not use it as a web service instead. With our wkhtmltopdf wrapper service you can easily move your website to the cloud and still use wkhtmltopdf with almost every command-line parameter available.

Example generating pdf from url

Example of generating pdf document of our home page, as grayscale and waiting 500ms for javascripts to finish executing. Home page is loaded with a viewport size of 1280x1024 pixels

{
     "url": "https://www.pdfbroker.io",
     "wkHtmlToPdfArguments": {
         "viewport-size": "1280x1024",
         "grayscale": "",
         "javascript-delay": "500"
     }
 }
    

Example generating pdf from inline markup

Example of generating pdf document using inline markup encoded as base64, and providing an image as a resource in the resources object

{
    "url": null,
    "htmlBase64String": "PCFET0NUWVBFIGh0bWw.... Content removed for readability.",
    "wkHtmlToPdfArguments": null,
    "resources": {
        "pdfbroker_logo.svg": "PHN2ZyBpZD0iTGFnZXJfMS.... Content removed for readability"
    }
}
    

Ignored wkhtmltopdf arguments

There are a few parameters to wkhtmltopdf that is ignored by our api for security reasons or because they make no sense using when you don't have access to standard output.
The following arguments will not be passed on to wkhtmtopdf:

  • manpage
  • help
  • H
  • h
  • extended-help
  • htmldoc
  • readme
  • license
  • read-args-from-stdin
  • readme
  • version
  • V
  • debug-javascript
  • no-debug-javascript

Valid wkhtmltopdf arguments

All arguments that are not listed above will be sent on to wkhtmltopdf. For a full list of arguments please checkout the wkhtmltopdf manpage https://wkhtmltopdf.org/usage/wkhtmltopdf.txt

Open API/Swagger specification

Full specification and more examples available on our Swagger page

Checkout Swagger documentation

Feedback

Feedback

Let us know what you think and help us improve