Loading…
Generate PDF's from any URL
API / HELP / DONATE

API

url2pdf.it provides an API for easy conversion from your own applications.
The API is very simple to use with only one endpoint /api accepting both GET and POST requests.

Give it a try, https://url2pdf.it/api?url=[Your URL]

POST /api example:

{ "format": "binary", "orientation": "portrait", "zoomFactor": 0.825, "html": "<h1>Test</h1>", "paperSize": "A4", "paperMargin": { "left": "1cm", "right": "1cm", "top": "1cm", "bottom": "1cm" }, "javascriptEnabled": true, "loadImages": true, "resourceTimeout": 8000 }

GET /api

This method is sometimes useful for testing purposes. Parameters are passed through the query string. Field names are exactly the same except for paperMargin.

paperMargin.left -> paperMarginLeft paperMargin.right -> paperMarginRight paperMargin.top -> paperMarginTop paperMargin.bottom -> paperMarginBottom"userAgent": "PDFify 1.0" Example: http://url2pdf.it/api?paperMarginLeft=4cm&zoomFactor=1&url=https://google.com

PHP Curl

Here is an example of how you can post using php curl.

$CurlConnect = curl_init(); curl_setopt($CurlConnect, CURLOPT_URL, 'https://url2pdf.it/api?url=http://google.com'); curl_setopt($CurlConnect, CURLOPT_POST, 1); curl_setopt($CurlConnect, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($CurlConnect, CURLOPT_POSTFIELDS, $request); curl_setopt($CurlConnect, CURLOPT_USERPWD, $login.':'.$password); $Result = curl_exec($CurlConnect); header('Cache-Control: public'); header('Content-type: application/pdf'); header('Content-Disposition: attachment; filename="url2pdf.it -> New PDF"'); header('Content-Length: '.strlen($Result)); echo $Result;

fileName
Set the PDF's file name or eave blank for the default name of the url.
format
Can be binary or base64. Default is binary.
orientation
Can be portrait or landscape. Default is portrait.
zoomFactor
You will often adjust this parameter to make your HTML design fit better into the PDF document. The sweet spot is between 0.7 and 0.8.

Zoom factor does not work when javascript is disabled. Default zoom is 1.

Additionally it can be set via css:

body { zoom: 0.85; }
html
HTML to load inside PhantomJs headless browser.
url
Opens the url and loads it to the page. *required
url
Opens the url and loads it to the page. *required
paperSize
A3 A4 A5 Legal Letter Tabloid
paperWidth /
paperHeight
mm cm in px No unit means px

Supply only paperSize or paperWidth and paperHeight only.
paperMargin
Borders around PDF page. Supported dimension units are:

mm cm in px No unit means px.
javascriptEnabled
Defines whether to execute the javascript code in the page or not. Defaults to true
loadImages
Defines whether to load the inlined images or not. Defaults to true
resourceTimeout
Defines the timeout after which any resource requested will stop trying and proceed with other parts of the page.

Default is 8000 (in milliseconds).
Powered by: Heroku | Open source