HTML to PDF API

Write your template once in HTML and CSS, with Liquid tags for your data. Send JSON from your app and get back a PDF.

  • No credit card needed
  • Free test PDFs
  • 2.0¢ per PDF on Starter
Your JSON data
POST /api/v2/templates/{template_id}/submissions
{
  "data": {
    "invoice_number": "INV-1042",
    "customer": {
      "name": "Brightwater Studio"
    },
    "items": [
      { "name": "Onboarding", "price": 1200 },
      { "name": "Support plan", "price": 450 }
    ],
    "total": 1650
  }
}
From your app, a script or an AI agent
Your HTML template
<h1>Fernway</h1>
<p>Invoice {{ invoice_number }}</p>
<p>Billed to {{ customer.name }}</p>
<table>
  {% for item in items %}
  <tr>
    <td>{{ item.name }}</td>
    <td>{{ item.price | currency }}</td>
  </tr>
  {% endfor %}
  <tr>
    <td>Total</td>
    <td>{{ total | currency }}</td>
  </tr>
</table>
HTML and CSS you write once
Your PDF
Fernway
Invoice INV-1042
Billed to Brightwater Studio
Description Amount
Onboarding $1,200.00
Support plan $450.00
Total $1,650.00
Payment is due within 14 days. Thank you for your business.
invoice-1042.pdf

Trusted by teams in lending, insurance, property and healthcare

  • Jones
  • Harvust
  • Northwoods
  • iENROLL by EMREACH
  • BloomerHealth
  • FlowEQ
  • NOCD
  • Leeway

Liquid tags for your data

Loop over line items, show a section only when it applies, and format amounts and dates as they print.

  • Loops for line items, and conditions for optional sections
  • Filters for money, dates, time zones and plurals
  • SCSS variables and nesting, or plain CSS
Liquid filters

Headers, footers and page numbers

Long documents run onto as many pages as they need, with your header and footer on every one.

  • A header and a footer on each page, in HTML and CSS
  • Page numbers, like "Page 2 of 3"
  • Page breaks where you want them, with CSS
Headers and footers

Any page size

Make letters, labels and ID cards from the same kind of template. Set the page once, in the template's settings.

  • Letter, Legal, Tabloid, A0 to A6 and CR80 cards
  • Your own width and height, in inches, millimeters or pixels
  • Margins you set, or none, with backgrounds to the edge
Page settings

Edit it in your browser

Write your HTML, CSS and Liquid in the template editor. It suggests your fields as you type a tag.

  • Tabs for the HTML, header, footer and SCSS
  • A field for each value your tags use
  • Preview the PDF with sample data
Fields from your tags

Generate a PDF in a few lines of code

Send the data, not the HTML. Your template stays in DocSpring, so changing it needs no deploy.

  • SDKs in ten languages, or any HTTP client
  • Create and update templates with the API too
  • Wait for the PDF, or let it run in the background
Create a template with the API
from docspring import Client

client = Client()
data = {"full_name": "Maya Chen", "monthly_income": 6200}
submission = client.create_submission(
    "tpl_1234567890abcdef01",
    {"data": data},
)
print(submission.files.pdf.download_url)

Test PDFs are free, unlimited and watermarked.

Features

Preview as you edit

The editor's Preview tab shows the PDF with your latest changes.

Web fonts

Use Google Fonts, or load your own fonts from any public URL.

Signatures and images

Print signatures, photos and barcodes from your data, and images you upload.

Password protection

Encrypt a PDF with a password that you send in the request.

Web forms

Share a form built from the template's fields, and get a PDF for each response.

Versions

Publish a version, so changes to the draft don't reach your integration.

No-code tools

Generate PDFs from Make, n8n, Zapier, Bubble and other tools.

US or EU hosting

Keep your documents in the US or the EU. SOC 2 Type II audited.

I spent a good two days trying to integrate with one of your competitors, and came away frustrated because it still wasn’t working. I was up and running with DocSpring in thirty minutes.
Scottie Schneider Founder & CEO, Followup Edge

Questions about HTML to PDF

Read the HTML templates guide

How does the HTML to PDF API work?

Write a template in DocSpring's editor in HTML and CSS, with Liquid tags where your data goes. Your app sends JSON to the API, and DocSpring fills in the template and sends back a link to the PDF. You never send HTML with a request or run a browser yourself.

Which HTML and CSS can I use?

DocSpring renders templates in Chrome, so modern CSS works: flexbox, grid, web fonts, and images from public URLs or that you upload. Styles are SCSS, so plain CSS works too, and you can use variables and nesting.

How do I put my data into the template?

With Liquid tags. Print a value with {{ customer.name }}, repeat a row for each line item with a for loop, and show a section only when it applies with an if tag. Filters format money, dates, time zones and plurals, and the signature tag prints a signature.

Can I add headers, footers and page numbers?

Yes. Write a header and a footer in HTML and they repeat on every page, with the page number and the number of pages if you want them. Use CSS page breaks to start a section on a new page.

What page sizes can I use?

Letter (the default), Legal, Tabloid, Ledger, A0 to A6 and CR80 cards, in portrait or landscape, or your own width and height. Set each margin, or none.

Is DocSpring secure enough for financial, insurance and healthcare documents?

DocSpring is SOC 2 Type II audited and HIPAA compliant, and keeps your documents in the US or the EU. We sign a BAA on every paid plan: contact [email protected] before you send protected health information. Enterprise customers can also run DocSpring on their own servers.

How much does a PDF from an HTML template cost?

Each PDF uses 4 credits for up to 10 pages. Very large files and long processing count as extra units. Test PDFs are free and watermarked.

Turn your HTML into PDFs today

Test PDFs are free and unlimited. No credit card needed.

Product news by email

New features and changes, once a month.