Overview

The PDFGate API offers straightforward HTTP endpoints for generating high-quality PDF files from either raw HTML content or public URLs. This page contains all the information you need to get started and integrate PDF generation into your application quickly and reliably.

Authentication

All API requests to PDFGate must be authenticated using an API key. Authentication is handled via the Authorization header in your HTTP requests.

To get started, log in to your PDFGate account and create an API key from the Settings page in the dashboard. Ensure the key is active before using it in your code.

Include the API key in your request headers like this:

Authorization: Bearer YOUR_API_KEY

PDFGate supports two types of API keys:

  • Production: live_xxxxxxxxxxxxxxx
  • Sandbox: test_xxxxxxxxxxxxxxx

Use sandbox keys for testing purposes and production keys in your live environment.

Rate limits

The PDFGate API uses different rate limits for each account type in the production environment. In the sandbox environment, the rate limits are the same for all account types.

EndpointProductionSandbox
POST /generate/pdf
Per account type:
  • Personal: 3
  • Starter: 5
  • Basic: 15
  • Professional: 20
  • Professional Plus: 30
Per account type:
  • Personal: Not Available
  • Starter: Not Available
  • Basic: 2
  • Professional: 2
  • Professional Plus: 2
GET /document40 concurrent requests10 concurrent requests
GET /file40 concurrent requests10 concurrent requests

Errors

CodeError
400Bad request
401Unauthorized
404Not found
422Unprocessable entity
429Too many requests
500Internal server error

Generate PDF

To create a PDF document, send either a URL or raw HTML in the request body. Include your API key in the headers and set the appropriate Content-Type.

By default, the endpoint returns a raw PDF file. If you prefer a structured response, you can include the jsonResponse field in your request to receive a JSON payload with metadata about the generated document.

Endpoint

POSThttps://api.pdfgate.com/v1/generate/pdf

Examples

NODE.JS
PYTHON
GOLANG
CURL
copy-integration-source-code-icon
const fetch = require("node-fetch");
const fs = require("fs");

const options = {
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer YOUR_API_KEY",
    },
    body: JSON.stringify({
        url: "https://en.wikipedia.org/wiki/PDF",
        pageSizeType: "a4",
    }),
};

fetch("https://api.pdfgate.com/v1/generate/pdf", options).then( async (result) => {
    if (result.status === 201) {
        result.body.pipe(fs.createWriteStream("file_name.pdf"));
    } else {
        const error = await result.json();
        console.log(error);
    }
});

Request body fields

html string required if url field is not provided
url string required if html field is not provided
jsonResponse boolean
Default: false
Returns JSON response instead of file stream.
pageSizeType enum
Default: ledger
Acceptable values
a0a1a2a3a4a5a6ledgertabloidlegalletter
width number
Custom PDF file width in pixels (px). It needs to be defined with the height field.
height number
Custom PDF file height in pixels (px). It needs to be defined with the width field.
orientation enum
Default: portrait
Acceptable values
portraitlandscape
header string
footer string
margin object
timeout number
Default: 30000
Maximum wait time to render the HTML content in milliseconds.
security object
javascript string
css string
emulateMediaType enum
Sets the CSS media type of the document.
Acceptable values
screenprint
waitForSelector string
Waits for specific CSS selector to be loaded. It will timeout in 30 seconds.
clickSelector string
Waits and then clicks a specific CSS selector.
waitForNetworkIdle boolean
Waits until there are no more network connections in the document.
httpHeaders object
Sets custom HTTP headers.
enableFormFields boolean NEW
If enabled, the generated PDF will include interactive form fields (e.g., text inputs, checkboxes) that users can fill out directly in PDF viewers.
Supported HTML tags
input[type='text'] input[type='checkbox'] textarea select
For digital signature field we support the following custom HTML tag
<pdfgate-signature-field />
metadata object
Sets custom data to your document record.

Available responses

File stream
{"id" : "6642381c5c61""status" : "completed""fileUrl" : "https://api.pdfgate.com/file/6642381c5c61""documentUrl" : "https://api.pdfgate.com/document/6642381c5c61""size" : 1620006"createdAt" : "2024-02-13T15:56:12.607Z"}

Get document

Retrieves a generated document object containing metadata and file details.

Endpoint

GEThttps://api.pdfgate.com/document/{documentId}

Examples

NODE.JS
PYTHON
GOLANG
CURL
copy-integration-source-code-icon
const fetch = require("node-fetch");

const options = {
    method: "GET",
    headers: {
        "Authorization": "Bearer YOUR_API_KEY",
    },
};

fetch("https://api.pdfgate.com/document/{documentId}", options).then( async (result) => {
    const data = await result.json();
});

Response

{"id" : "6642381c5c61""status" : "completed""fileUrl" : "https://api.pdfgate.com/file/6642381c5c61""documentUrl" : "https://api.pdfgate.com/document/6642381c5c61""size" : 1620006"createdAt" : "2024-02-13T15:56:12.607Z"}

Get file

Retrieves a raw PDF file previously generated.

Note: To access a generated file, the “Save files for one month” option must be enabled in your Dashboard's settings. This option is disabled by default.

Endpoint

GEThttps://api.pdfgate.com/file/{documentId}

Examples

NODE.JS
PYTHON
GOLANG
CURL
copy-integration-source-code-icon
const fetch = require("node-fetch");
const fs = require("fs");

const options = {
    method: "GET",
    headers: {
        "Authorization": "Bearer YOUR_API_KEY",
    },
};

fetch("https://api.pdfgate.com/file/{documentId}", options).then( async (result) => {
    result.body.pipe(fs.createWriteStream("file_name.pdf"));
});

Response

File stream