This site uses cookies for better user experience. To use HTML PDF API, you must agree to our Privacy policy, including Cookie policy.
We are using cURL in our examples. Open quick tutorial if you need help.
cURL is command line tool on Linux and Mac for making HTTP/HTTPS and many other requests.
Usage: curl [options] [url]
-H, --header <header> |
(HTTP) Extra header to use when getting a web page. You may specify any number of extra headers. |
-d, --data <data> |
(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded. |
-F, --form <name=content> |
(HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multipart/form-data according to RFC 2388. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the > makes a text field and just get the contents for that text field from a file. |
More information on: http://curl.haxx.se/docs/manpage.html
curl -H 'Authentication: Token <your token>' \ -d 'url=http://htmlpdfapi.com/examples/example.html' \ 'https://htmlpdfapi.com/api/v1/pdf' > result.pdf
With multiple options
curl -H 'Authentication: Token <your token>' \ -d 'url=http://htmlpdfapi.com/examples/example.html' \ -d 'margin_left=5cm' \ -d 'margin_right=5cm' \ 'https://htmlpdfapi.com/api/v1/pdf' > result.pdf
curl -H 'Authentication: Token <your token>' \ -d 'html=<h1>HTML PDF API is cool!</h1>' \ 'https://htmlpdfapi.com/api/v1/pdf' > result.pdf
curl -H 'Authentication: Token <your token>' \ -F 'file=@example.html' \ 'https://htmlpdfapi.com/api/v1/pdf' > result.pdf
Download example.html and don't forget to check path to example.html file.
curl -H 'Authentication: Token <your token>' \ -F 'file=@example.zip' \ 'https://htmlpdfapi.com/api/v1/pdf' > result.pdf
Download example.zip and don't forget to check path to example.zip file.
curl -H 'Authentication: Token <your token>' \ -d 'url=http://htmlpdfapi.com/examples/example.html' \ -d 'ext=jpg' \ -d 'width=2000' \ -d 'height=2000' \ -d 'zoom=2' \ 'https://htmlpdfapi.com/api/v1/image' > result.jpg