PDF Mage API for developers
We provide a simple yet powerful API for creating top quality PDF files from HTML markup or a URL.
The interface is located at the address https://pdfmage.org/pdf-api/v1
API uses REST architecture. The parameters are sent using POST method in the request body in “key=value” format or in JSON. The format is determined on client side, by the providing the "Content-Type" header:
- For “key=value” parameters Content-Type should be: application/x-www-form-urlencoded
- For JSON parameters Content-Type should be: application/json
The system will normally respond with HTTP 200 status, sending a JSON response body which will have a "Success" parameter, and optional "Error" message and "Data":
Requests are authenticated based on the "X-Api-Key" HTTP header, which should contain your unique API key. API keys can be obtained after purchasing API access.
If the request does not have a header with authentication information, or the information sent in the request is incorrect, the system will return a HTTP 401 status – Unauthorized.
To check interaction with API you can call a test method at https://pdfmage.org/pdf-api/v1/sample without sending any parameters. The system will return a sample PDF download URL.
Generate PDF from HTML
To generate PDF from custom HTML, make a request to the following address: https://pdfmage.org/pdf-api/v1/process. These are the parameters you can use:
HTML markup that needs to be converted to PDF
* Required if TargetUrl parameter is not specified
The URL at which HTML page is located (used to download scripts, styles, images and other files needed for HTML page to be displayed properly)
* Required if Html parameter is not specified
|PageWidth||Numeric||No||HTML viewer width in pixels (default is 1024)|
Determines PDF page orientation. Possible values are:
|SinglePage||Boolean||No||Determines whether to split PDF file into pages, or use single page regardless of HTML page size|
|CompressPdf||Boolean||No||Determines whether to compress images and other resources for reducing PDF size|
|HideImages||Boolean||No||Determines whether to hide images in PDF|
|DisableLinks||Boolean||No||Determines whether to disable clickable links in PDF|
|DisplayDateInFooter||Boolean||No||Determines whether to display creation date and time in PDF footer|
|PdfPassword||String||No||Set this to protect your PDF with a password|
|AllowPrinting||Boolean||No||Determines whether to allow printing of the resulting PDF|
|AllowCopying||Boolean||No||Determines whether to allow copying content from the resulting PDF|
|AllowEditing||Boolean||No||Determines whether to allow editing of the resulting PDF|
Customize paper size of the resulting PDF. Possible values are:
|Numeric||No||Set these values to customize PDF page margins. Note: margins are measured in points (1 point = 1/72 inch)|
Check your API key
To check your API key, make a request to the following address: https://pdfmage.org/pdf-api/v1/check-key without sending any parameters. You should pass your key in request headers, like for all other methods.
Our API is currently rate limited. You may only perform requests from a single IP address every 5 seconds. If you attempt to make more frequent requests, the system will return a HTTP 409 status – Conflict.