HTML to PDF API

Design PDF templates with HTML, CSS, and Liquid, then generate pixel-perfect documents from JSON data. Rendered with a headless Chrome pipeline, so your PDFs look exactly like your markup.

Start Free Trial The DocSpring HTML template editor with a Liquid template

HTML in, PDF out

Templates support the Liquid templating language (variables, loops, and conditions) so you can design any invoice, report, or statement.

<h1>Invoice #{{ invoice_number }}</h1>
<table>
  {% for item in line_items %}
    <tr>
      <td>{{ item.description }}</td>
      <td>{{ item.amount | money }}</td>
    </tr>
  {% endfor %}
  <tr>
    <td><strong>Total</strong></td>
    <td><strong>{{ total | money }}</strong></td>
  </tr>
</table>

<style>
  h1 { font-family: Helvetica, sans-serif; color: #1b2432; }
  table { width: 100%; border-collapse: collapse; }
</style>

Read the HTML templates guide

Built for dynamic documents

Real browser rendering

Headless Chrome renders your templates, so modern CSS, custom fonts, and embedded images all work.

Liquid templating

Variables, loops, conditions, and formatting filters. Send JSON data and DocSpring merges it into your template, including line items, totals, and conditional sections.

Any page size

Standard page sizes, custom width and height, with configurable margins.

The same simple API

HTML templates use the same generate-PDF API and SDKs as every other DocSpring template: POST JSON, download the PDF, or receive a webhook.

HTML to PDF FAQ

How does DocSpring convert HTML to PDF?

Your HTML and CSS are rendered with a headless Chrome pipeline, so the generated PDF looks exactly like the page you designed. Modern CSS, custom fonts, and embedded images all work.

Can my HTML templates include dynamic data?

Yes. HTML templates support the Liquid templating language: variables, loops, conditions, and filters. POST JSON data to the API and DocSpring merges it into your template. This is ideal for invoices with line items, reports, and statements.

Can I control the page size and margins?

Yes. Templates support standard page sizes, custom width and height (down to ID-card size), and configurable margins.

How do I test my templates?

You can generate free watermarked test PDFs that never count against your quota, so you can iterate on a template until it is pixel-perfect. The template editor also includes a live preview tab that updates as you edit your template.

Turn your HTML into PDFs in minutes

Sign up for a free trial and try out DocSpring with your own PDFs.