HTML to PDF API for Developers

Convert fully styled HTML pages including CSS, JavaScript, and fillable forms into high-fidelity PDFs with a single API call.

check-mark-icnNo credit card required

Why Choose Our HTML to PDF API

Html to pdf api

Convert web pages or raw HTML into pixel-perfect PDFs with our PDF generation API that supports modern CSS, JavaScript, and interactive AcroForm fields like text inputs, checkboxes, and digital signature fields. Designed for developers, our API uses a headless browser to accurately render dynamic layouts, custom fonts, and fully interactive forms just like they appear in the browser.

rendering

Full HTML/CSS/JS Rendering

Powered by headless Google Chrome, our API renders your HTML exactly as it appears in the browser with pixel-perfect CSS, JS, and font support.

Interactive Form Fields

Interactive Form Fields Support

Turn HTML forms into interactive PDFs with support for inputs, checkboxes, selects, textareas, and signature fields. No extra libraries are required.

PDF Control

Precise Page Layout and PDF Control

Customize PDF page size, margins, orientation, and apply automatic or manual page breaks using standard CSS rules. Perfect for pixel-perfect invoices, reports, or multi-page forms with layout precision you can trust.

Custom Headers and Footers

Custom Headers and Footers

Easily add headers and footers to your PDFs, including page numbers, dynamic titles, logos, or footnotes. Designed for multi-page documents like invoices, reports, and statements.

Simple and Reliable REST API

Simple and Reliable REST API

Send raw HTML or a public URL to our HTML to PDF API, and receive a high-fidelity PDF in seconds. No headless browser setup or infrastructure required. Just one API call and you're done.

Secure, Scalable, and Built for Real-World Workloads

Secure, Scalable, and Built for Real-World Workloads

Generate PDFs at scale with reliable performance and secure endpoints. Ideal for mission-critical workflows such as invoices, reports, and legal documents.

Infrastructure

Uptime & SLAs

Backed by a 99.9% uptime SLA. Our infrastructure is monitored 24/7 to ensure reliable performance, with automatic failover and fast recovery in place.

privacy

Data Privacy

When you use our API, your files are processed securely and never stored unless you choose otherwise.

PDF Generation Quick Start


Use a single API call to generate PDFs from any programming language.

CURL
NODE.JS
PYTHON
GOLANG
copy-integration-source-code-icon
curl --header "Content-Type: application/json" \
--header "Authorization: Bearer YOUR_API_KEY" \
--request POST \
--data '{"pageSizeType":"a4", "url":"https://en.wikipedia.org/wiki/PDF"}' \
https://api.pdfgate.com/v1/generate/pdf

API Parameters

API parameters

These parameters control how the PDF is generated from your HTML input. All parameters are passed via JSON in the POST body.

Parameter nameTypeDescriptionValue example
htmlstringThe raw HTML content to be converted into a PDF. This can include full HTML documents or fragments, with support for inline styles, custom fonts, JavaScript, and media queries. The HTML will be rendered as a PDF using a headless browser.
<!DOCTYPE html> <html> <head></head> <body style='padding:10px'> <div> <h1>Test document</h1> <p>Some text...</p> </div> </body> </html>
urlstringThe public URL of the web page to convert into a PDF. The page must be accessible over HTTPS and should return a complete HTML document.https://en.wikipedia.org/wiki/PDF
jsonResponsebooleanWhen set to true, the API will return a JSON response instead of streaming the generated PDF file. The JSON includes a secure download URL and metadata about the PDF. This is useful for workflows where you want to store, inspect, or delay the download of the PDF rather than receiving it immediately in the response body.
true
false
pageSizeTypestringSpecifies the paper size for the generated PDF.
a0
a1
a2
a3
a4
a5
a6
ledger
tabloid
legal
letter
widthnumberSets a custom width for the generated PDF in pixels. This overrides the default paper size and is typically used for responsive or non-standard layouts such as receipts, banners, or custom reports. When using width, you should also set the height parameter. This option is ideal for precise control over PDF dimensions.800
heightnumberSets a custom height for the generated PDF in pixels. Use this to define non-standard page sizes for dynamic layouts. When specifying height, you should also provide the width parameter. This allows full control over the final PDF dimensions and layout.1000
orientationstringSpecifies the page orientation for the generated PDF. Accepted values are portrait and landscape. This setting affects the layout and flow of content across the page, especially for horizontal designs. Defaults to portrait if not specified.
portrait
landscape
headerstringThe HTML content to display as a fixed header on every page of the generated PDF. This can include text, logos, tables, or styled elements, and supports inline CSS for full customization. Ideal for adding company branding, document titles, page numbers, or dates to the top of each page.
<div style="text-align:center;"> <span class="date"></span> | Page <span class="pageNumber"></span> </div>
footerstringThe HTML content to display as a fixed footer on every page of the generated PDF. Supports text, images, tables, and inline CSS for full customization. Common uses include adding page numbers, disclaimers, timestamps, or company contact information at the bottom of each page.
<div style="text-align:center;"> Custom footer text </div>
marginobjectSets the page margins for the generated PDF in pixels. Accepts an object with optional properties: top, right, bottom, and left. This allows precise control over content spacing and layout, especially when using headers, footers, or print-optimized designs.
{ "top": "1cm", "bottom": "1cm", "left": "1cm", "right": "1cm" }
timeoutnumberSpecifies the maximum time to wait for the HTML content to fully load and render before generating the PDF, in milliseconds. This includes time for scripts, styles, fonts, and images to load. Useful for pages with dynamic or slow-loading content. Default is 30 seconds if not specified.60000
securityobjectApplies encryption and security settings to the generated PDF using 128-bit AES encryption. Use this to protect sensitive documents with password access, restrict printing or editing, and comply with PDF security standards.
{ "userPassword": "123456", "userPassword": "abcdef", "disablePrint": true, "disableCopy": true, "disableEditing": true }
javascriptstringDefines custom JavaScript code to be executed after the HTML content is loaded but before the PDF is generated. The script runs inside the page context using a headless browser.
function addElement() { const element = document.createElement('div'); element.textContent = 'hello world'; element.style.cssText = 'background-color: lightgreen'; document.body.append(element); } addElement();
cssstringCustom CSS styles to apply to the HTML content before rendering it to PDF. This allows you to override default styles, add branding, adjust layouts, or control print-specific formatting.
body {background-color: #d2d9d4;}
emulateMediaTypestringSets the CSS media type used when rendering the HTML to PDF. Accepted values are screen and print. This controls which CSS media queries are applied. Use print to apply print-specific styles (e.g., hide navigation, adjust layout), or screen to render the PDF as it appears in a browser.
screen
print
waitForSelectorstringDelays PDF generation until a specific CSS selector is present in the DOM. The renderer will wait until the element matching the selector appears or until the timeout is reached..classSelector
clickSelectorstringWaits for an element matching the given CSS selector to appear on the page, then simulates a click before rendering the PDF. Useful for triggering UI interactions such as opening modals, expanding sections, loading hidden content, or accepting cookie banners. This action occurs after the page loads but before PDF generation begins.button#button_id
waitForNetworkIdlebooleanWhen set to true, this delays PDF generation until the page has no active network connections. This ensures that all resources such as images, fonts, and JavaScript-loaded content are fully loaded before rendering. It is especially useful for pages with asynchronous or delayed content loading.
true
false
httpHeadersobjectDefines custom HTTP headers to be sent when loading the HTML or URL for PDF generation. Useful for passing authentication tokens, cookies, or custom headers required by your web application.
{ "Accept-Language": "fr, en;q=0.8" }
enableFormFieldsbooleanWhen set to true, the generated PDF will include interactive AcroForm fields that users can fill out directly in PDF viewers such as Adobe Acrobat or browser-based PDF readers. This is ideal for creating fillable forms, applications, contracts, or surveys from HTML input elements like <input>, <select> and <textarea>.
true
false
metadataobjectAdds custom metadata to the document record. This data is not embedded in the PDF itself but can be used for tracking, tagging, or associating the PDF with external systems. You can include any key-value pairs relevant to your application.
{ "clientId": "some_value" }

Live Demo

Free Templates

Find below our free templates. The source code is available on our GitHub page for you to use in your own projects.
testimonial 1testimonial 1testimonial 1
Have ideas for new templates or improvements?
Feel free to reach out!

Pricing plans

Billed MonthlyBilled Yearly
PlanMonthly ConversionsMonthly PriceOverage
Personal1,000$9$0.05Get started
Starter5,000$26$0.01Get started
Basic20,000$60$0.003Get started
Professional50,000$100$0.002Get started
Professional Plus200,000$300$0.001Get started

What is included?

Free trial for 7 days
Full API features
Unlimited file size

What are overages?

Every plan includes a monthly PDF conversion limit. If you go over this limit, we charge a predictable per-unit fee for the extra usage. Overages ensure your service continues without interruption, and you only pay for what you use.

Find out more details on our Pricing page