DocRaptor HTML TO PDF API

How to Convert HTML-to-PDF with DocRaptor

With DocRaptor's unique HTML to PDF API, powered by the Prince PDF converter, it's easy to convert HTML, CSS, and JavaScript into PDF and XLS documents. Below are working code examples for creating documents. Our API reference lists all the generation options and our style and formatting guides will help make it look perfect.

Select Your Language

Make a direct API request

Not using any of the above languages? Test the API in Postman or simply send a POST request to https://YOUR_API_KEY_HERE@api.docraptor.com/docs (yes, that key works!) with the below JSON payload:

{
  "test": true,                                                    // test documents are free but watermarked
  "document_content": "<html><body>Hello</body></html>",           // supply content directly
  // "document_url": "https://docraptor.com/examples/invoice.html", // or use a url
  "type": "pdf",                                                   // pdf or xls or xlsx
  // "javascript": true,                                           // enable JavaScript processing
  // "prince_options": {
  //   "media": "screen"                                           // use screen styles instead of print styles
  //   "baseurl": "http://hello.com"                               // pretend URL when using document_content
  // }
}

For more information, see our complete API reference.

curl Example

Here's an example of that POST request that you can copy and paste:

curl https://YOUR_API_KEY_HERE@api.docraptor.com/docs \
  --fail --silent --show-error \
  --header "Content-Type:application/json" \
  --data '{"test": true,
           "document_url": "https://docraptor.com/examples/invoice.html",
           "type": "pdf" }' > docraptor.pdf

Next Steps

Ready to get started? Try DocRaptor for free with unlimited test documents.