Convert HTML to PDF in seconds. Simple, Secure and Scalable

Convert your HTML or web pages into high-quality PDFs effortlessly. Our HTML to PDF API is designed for developers and businesses who need accurate, reliable, and scalable PDF generation. It delivers pixel-perfect rendering, supports fillable form fields, and handles complex layouts with ease.

check-mark-icnNo credit card required

Main Features

Advanced Rendering Engine

PDFGate - html to pdf rendering engine

Powered by Google Chrome

The API uses the latest Chrome rendering engine to generate PDFs that look exactly as they do in the browser, ensuring pixel-perfect accuracy with full CSS and JavaScript support.

PDFGate - responsive html to pdf api

Responsive Page Support

Easily convert responsive designs into PDFs that adapt beautifully across mobile, tablet, and desktop layouts. Your content will maintain its layout and readability on every device.

PDFGate - front-end frameworks

Framework-Friendly

Seamlessly render pages built with your favorite front-end frameworks and tools such as React, Angular, Tailwind, Vue.js, and more. No additional setup is required.

Create Fillable PDFs

Add Interactivity and Collect User Data from Your PDFs

Transform HTML inputs into PDF fields

Convert standard HTML input elements directly into interactive PDF fields without any additional configuration.

Support for all the common field types

Create fully interactive PDFs with text fields, date fields, dropdowns, radio buttons, checkboxes, multi-select lists, text areas, and digital signature fields.

Customize appearance and behavior

Adjust the look and feel of each field by defining background colors, borders, and font sizes. Control field behavior with standard validations, prefilled values, and more.

Combine with Other Endpoints

Use it alongside other endpoints such as Flatten PDF or Extract Data to create a complete workflow for collecting, processing, and securing PDF form data.

Additional Customizations

PDFGate - pdf headers, footers and perfect PDF layout

Fine-Tune Every Detail

Control page margins, headers, and footers to achieve the perfect layout for your PDFs.

PDFGate - customize PDF paper sizes and more

Flexible Page Options

Generate PDFs using standard paper sizes or define custom page width and height. Select specific page ranges to include only the content you need.

PDFGate - lazy load images to PDF from HTML

Enhanced Rendering Control

Enable lazy loading for images, inject custom JavaScript or CSS scripts, and set page delays to ensure complete content rendering.

PDFGate - html to pdf - advanced interaction features

Advanced Interactions

Wait for specific elements to appear or trigger clicks before capturing the page, giving you full control over dynamic and interactive content.

Quick Start


Get up and running in minutes with a simple API call. Our HTML to PDF API is designed for effortless integration into your existing workflows, whether you use Node.js, Python, PHP, or any other language. Use the examples to start converting your HTML into high-quality PDFs instantly.

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

Ready-to-Use Templates

Jump-start your project with our free HTML to PDF templates. Our GitHub repository includes two customizable invoice templates and one receipt template, all fully compatible with the HTML to PDF API. Clone the repo, modify the design, and instantly start generating professional invoices and receipts.

Explore the code →
  • Invoice template — Classic layout with line items and totals
  • Receipt template — compact summary with payment details
  • Invoice template — Modern layout with highlighted totals

Full API Parameter List

Html

The 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 our headless browser.

Url

The public URL of the web page to convert into a PDF. The page must be accessible over the internet and should return a complete HTML document.

Json Response

When 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.

Page Size Type

Specifies the paper size for the generated PDF. Such as A4, Tabloid and Letter.

Page Ranges

Defines the page range to include in the PDF.

Width

Sets 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. When using width, you should also set the height parameter. This option is ideal for precise control over PDF dimensions.

Height

Sets 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.

Orientation

Specifies 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. The API defaults to portrait if it is not specified.

Scale

Defines the page scale factor used when generating the PDF. Accepts values between 0.1 and 2.

Header

The 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.

Footer

The 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.

Margin

Sets 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.

Timeout

Specifies how long the API waits (in milliseconds) for the HTML content to fully load and render before generating the PDF. This option is useful for pages with dynamic or slow-loading content. The default value is 15 minutes, and in most cases you won't need to change it. You may want to reduce the timeout when debugging, especially if a page is hanging and you want the request to fail faster.

Delay

Adds a delay (in milliseconds) before converting the HTML content into a PDF. This is useful when asynchronous content requires additional time to fully render.

Load Images

When enabled, the API waits for all images to finish loading before generating the PDF. This helps prevent missing or partially rendered images.

Javascript

Defines custom JavaScript code to be executed after the HTML content is loaded but before the PDF is generated.

Css

Custom 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.

Emulate Media Type

Sets 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.

Wait For Selector

Delays 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.

Click Selector

Waits 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.

Click Selector Chain Setup

Provides advanced control for handling cookie banners, consent dialogs, pop-ups, and multi-step UI interactions before the PDF is generated. This option extends and improves upon the simpler clickSelector parameter by allowing a sequence of interactions to be executed in order. When this parameter is defined, the clickSelector field is ignored.

Wait For Network Idle

When 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.

User Agent

Specifies the user agent string used when rendering the HTML, allowing you to control how the content is served and displayed.

Http Headers

Defines 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.

Enable Form Fields

When 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>.

Pre Signed Url Expires In

Allows you to temporarily view the generated PDF in the browser without authorized access, using a secured URL that expires after the time you specify. The value is provided in seconds, and the maximum expiration time is 1 day.

Metadata

Adds custom metadata to the document record. This information is not embedded in the PDF file itself, but can be used for tracking, tagging, or associating the document with related data in your system. You may include any key-value pairs relevant to your application.

Frequently Asked Questions


What is an HTML to PDF converter?

It is a tool or an online service that can transform web content (HTML, CSS) into a PDF file. It is used by software teams to generate reports, invoices, or other documents because of its simplicity.

Can I add a watermark or protect PDFs with a password?

Yes. Our API includes dedicated endpoints for PDF watermarking and encryption. After generating a PDF from HTML, you can apply password protection and/or a watermark using the appropriate endpoints.

Can I schedule batch HTML to PDF conversions?

Yes, batch conversions are supported. Be sure to manage concurrency according to the limits defined in your plan.

Do you have SDKs or client libraries for different programming languages?

We do not currently offer SDKs. However, our API is easy to use with any language, and it is well documented. Our official SDKs are coming soon to make your integration even easier.