HTML to PDF API

Convert HTML files into PDF documents using a REST API.

Choose between OpenHTMLtoPDF and Chromium rendering according to your document requirements.

Key features

Multiple rendering engines

Select OpenHTMLtoPDF or Chromium depending on the conversion mode.

CSS print layouts

Define page size, margins, orientation and page breaks using CSS print rules.

Conversion modes

Choose the rendering mode that matches your document requirements.

BASIC

Fast conversion with OpenHTMLtoPDF. Recommended for simple HTML documents, reports and invoices.

ADVANCED Default mode

Chromium rendering for modern HTML and CSS without external resources. This is the default mode.

ULTRA

Chromium rendering with support for external stylesheets, fonts and images. A Basic license or higher is required for output without the evaluation watermark.

Free users can evaluate ULTRA, but the resulting PDF contains a permanently embedded watermark on every page.

Control PDF layout with CSS

Use CSS print rules to control page size, margins, orientation and pagination. Without an @page rule, A4 pages with 10 mm margins are applied automatically.

@page {
    size: A4;
    margin: 20mm;
}

body {
    font-family: Arial, sans-serif;
}

h1 {
    color: #1565c0;
}

Use cases

  • Generate PDF reports from HTML templates.
  • Convert invoice layouts into PDF documents.
  • Generate printable documents with CSS pagination.

Quick start

Upload an HTML file using multipart/form-data, select a conversion mode and authenticate using a JWT Bearer Token.

HTTP method

POST /api/v1/convert/file/html-to-pdf

Request parameters

file
Required multipart file (.html or .htm).
mode
Optional query parameter: BASIC, ADVANCED or ULTRA. Default: ADVANCED.
Authorization
JWT Bearer Token in the Authorization header.

Successful response

The API returns HTTP 200 with an application/pdf response containing the generated document.

Content-Disposition: attachment; filename="document.pdf"

Response headers also identify the rendering engine, its version, the selected mode and processing time.

Important considerations

  • JavaScript is not executed during rendering.
  • External resources require ULTRA mode.
  • Embedded CSS is recommended whenever possible.
  • File processing and request limits apply.
View rate limits

Related APIs and resources

loader