This documentation will help you to get started and convert HTML to PDF with ease. You will find code samples in Shell, JavaScript and PHP.
Authenticate your account by including the bearer token in the API requests. You can manage your API Keys within the Dashboard.
We recommend you to set the sandbox
parameter to true
when starting with PDFStack.
When enabled the sandbox
parameter adds a watermark to your generated PDF files but does not count the conversions against your quota.
Here's a list of all errors than can occur when using our API.
Code | Status | Description |
---|---|---|
200 | OK | Request successful |
400 | Bad request | Request was invalid |
401 | Unauthorized | No API key was found |
403 | Forbidden | The API key is invalid |
405 | Method Not Allowed | Incorrect HTTP method provided |
429 | Too Many Requests | Client is rate limited |
500 | Internal Server Error | Server error, please try again later or contact support |
If you need any help or jusst want to say hi, feel free to reach out to our support team.
Use our contact form here and we will be in touch as soon as possible.
This endpoint allows you to generate a PDF document. The source parameter is the only mandatory body parameter. All other parameters are optional.
Parameter | Type | Description |
---|---|---|
source | string | A valid URL or HTML. |
base64 | boolean | Outputs PDF response as base64 string. |
sandbox | string | Credit will not be used, PDF will be watermarked |
password | string | Password protect PDF |
author | string | Set author metadata |
title | string | Sets document title |
landscape | boolean | Outputs lanscape |
paperFormat | string | Allowable values: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6 |
scale | number | Allowable range: 0.1 to 2 |
pageRange | number | Allowable values: number example 1 or range example 1-3 |
timeout | number | Maximum time in milliseconds |
enableJavaScript | boolean | Enable JavaScript execution |
disableLinks | boolean | Disable hyperlinks in PDF |
disableImages | boolean | Disable images in PDF |
disableBackground | boolean | Disable background images in PDF |
cssMedia | string | Allowable values: print, screen |
pageMargins | object |
Unit of measurement for margins. Possible values are:
|
headerTemplate | string | Header added to every page. Top margin may need to be adjusted depending on header height. The following can be injected using a classes: date, title, url, pageNumber, totalPages |
footerTemplate | string | Footer added to every page. Bottom margin may need to be adjusted depending on footer height. The following can be injected using a classes: date, title, url, pageNumber, totalPages |
auth | object | Credentials for accessing password protected website with Basic Authentication |
httpHeaders | object | Array of http headers to send with request |
watermark | string | Watermark to be added to each page. This can be a base64 data image or URL |
webhook | string | A POST will sent to the webhook URL. If the webhook fails to respond with a 200 status code, an error will be displayed and a credit used. Please test in sandbox mode to avoid credit usage. |
Can be a URL or html
"source" : "https://www.wikipedia.org",
"source" : "<h1>TEST</h1>",
Outputs PDF response as base64 string
"base64" : true,
Credit will not be used, PDF will be watermarked
"sandbox" : true,
Password protect PDF
"password" : "somepassword",
Sets author metadata
"author" : "Some Author",
Sets document title
"title" : "Some Title",
Outputs landscape
"landscape" : true,
Outputs paper size. Allowable values: Letter, Legal, Tabloid, Ledger, A0, A1, A2, A3, A4, A5, A6.
"paperFormat" : "letter",
Sets scale (zoom) level
"scale" : 1.5,
Pages to print
"pageRange" : "1-2",
Enable JS execution
"enableJavascript" : false,
Disable hyperlinks in PDF
"disableLinks" : false,
Disable images in PDF
"disableImages" : false,
Disable background images in PDF
"disableBackground" : false,
CSS style sheet to use
"cssMedia" : "print",
The following request will create a conference badge as a PNG image. By setting the.
"pageMargins" : {
"top" : 20,
"right" : 20,
"bottom" : 20,
"left" : 20
},
The following request will create a conference badge as a PNG image. By setting the.
"headerTemplate" : "<div style='width: 100%; text-align: center; padding:10px 0 10px 0; font-size: 15px;'><span>Header Message</span> - <span class='title'></span></div>",
The following request will create a conference badge as a PNG image. By setting the.
"footerTemplate" : "<div style='width: 100%; text-align: center; padding:10px 0 10px 0; font-size: 15px;'><span>Footer Message</span> - <span class='title'></span></div>",
The following request will create a conference badge as a PNG image. By setting the.
"auth" : {
"username" : "foo",
"password" : "bar"
},
The following request will create a conference badge as a PNG image. By setting the.
"httpHeaders" : {
"User-Agent" :"XYZ",
"Referrer" :"PDFStack"
},
The following request will create a conference badge as a PNG image. By setting the.
"watermark" : "https://example.com/image.png
"watermark" : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3/OAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAANCSURBVEiJtZZPbBtFFMZ/M7ubXdtdb1xSFyeilBapySVU8h8OoFaooFSqiihIVIpQBKci6KEg9Q6H9kovIHoCIVQJJCKE1ENFjnAgcaSGC6rEnxBwA04Tx43t2FnvDAfjkNibxgHxnWb2e/u992bee7tCa00YFsffekFY+nUzFtjW0LrvjRXrCDIAaPLlW0nHL0SsZtVoaF98mLrx3pdhOqLtYPHChahZcYYO7KvPFxvRl5XPp1sN3adWiD1ZAqD6XYK1b/dvE5IWryTt2udLFedwc1+9kLp+vbbpoDh+6TklxBeAi9TL0taeWpdmZzQDry0AcO+
The following request will create a conference badge as a PNG image. By setting the.
"webhook" : "https://apistack.io/webhook"
"data" : {
"file" :"{base64 encode pdf}",
}