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
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
}
}
<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>
| Description | Amount |
|---|---|
| Onboarding | $1,200.00 |
| Support plan | $450.00 |
| Total | $1,650.00 |
Trusted by teams in lending, insurance, property and healthcare
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
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
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
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
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
import { Client } from 'docspring-ts'
const client = new Client()
const templateId = 'tpl_1234567890abcdef01'
const submission = await client.createSubmission(templateId, {
data: { full_name: 'Maya Chen', monthly_income: 6200 },
})
console.log(submission.files.pdf?.download_url)
import { Client } from 'docspring'
const client = new Client()
const templateId = 'tpl_1234567890abcdef01'
const submission = await client.createSubmission(templateId, {
data: { full_name: 'Maya Chen', monthly_income: 6200 },
})
console.log(submission.files.pdf.download_url)
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)
require 'docspring'
client = DocSpring::Client.new
submission = client.create_submission(
'tpl_1234567890abcdef01',
{ data: { full_name: 'Maya Chen', monthly_income: 6200 } }
)
puts submission.files.pdf.download_url
<?php
require 'vendor/autoload.php';
$client = new DocSpring\Api\Client();
$data = ['full_name' => 'Maya Chen', 'monthly_income' => 6200];
$submission = $client->createSubmission(
'tpl_1234567890abcdef01',
['data' => $data]
);
echo $submission->getFiles()->getPdf()->getDownloadUrl() . "\n";
import com.docspring.*;
public class Example {
public static void main(String[] args) throws Exception {
CreateSubmissionRequest body = new CreateSubmissionRequest()
.putDataItem("full_name", "Maya Chen")
.putDataItem("monthly_income", 6200);
Submission submission = new Client().createSubmission(
"tpl_1234567890abcdef01", body, null, null);
GeneratedFile pdf = submission.getFiles().getPdf();
System.out.println(pdf.getDownloadUrl());
}
}
using DocSpring.Client.Model;
var client = DocSpring.Sdk.NewClientFromEnv();
var data = new Dictionary<string, object> {
["full_name"] = "Maya Chen",
["monthly_income"] = 6200,
};
var response = await client.CreateSubmissionAsync(
"tpl_1234567890abcdef01",
new CreateSubmissionRequest { Data = data });
var submission = response.Created();
Console.WriteLine(submission.Files.Pdf.DownloadUrl);
import "github.com/docspring/docspring-go/v4"
client := docspring.NewClient("", "")
submission, _, err := client.CreateSubmission(
context.Background(), "tpl_1234567890abcdef01",
).Body(docspring.CreateSubmissionRequest{Data: map[string]any{
"full_name": "Maya Chen", "monthly_income": 6200,
}}).Execute()
if err != nil {
log.Fatal(err)
}
fmt.Println(submission.Files.Pdf.GetDownloadUrl())
conn = Docspring.Connection.new()
{:ok, %Docspring.Model.Submission{} = submission} =
Docspring.Api.Client.create_submission(
conn,
"tpl_1234567890abcdef01",
%{data: %{full_name: "Maya Chen", monthly_income: 6200}}
)
IO.puts(submission.files.pdf.download_url)
use docspring::models::CreateSubmissionRequest as Request;
use docspring::{Api, CreateSubmissionParams as Params};
use serde_json::{from_value, json};
let client = docspring::Client::from_env()?;
let data = json!({"full_name": "Maya Chen", "monthly_income": 6200});
let body = Request { data: from_value(data)?, ..Default::default() };
let params = Params::builder()
.template_id("tpl_1234567890abcdef01").body(body).build();
let submission = client.create_submission(params).await?;
let pdf = submission.files.pdf.and_then(|f| f.download_url);
println!("{}", pdf.unwrap_or_default());
API=https://sync.api.docspring.com/api/v2
curl -s "$API/templates/tpl_1234567890abcdef01/submissions" \
-u "$DOCSPRING_TOKEN_ID:$DOCSPRING_TOKEN_SECRET" \
-H "Content-Type: application/json" \
-d '{
"data": { "full_name": "Maya Chen", "monthly_income": 6200 }
}' \
| jq -r '.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.

Questions about HTML to PDF
Read the HTML templates guideHow 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.
Compare HTML to PDF APIs
Rendering, templates, hosting and pricing, side by side.
Turn your HTML into PDFs today
Test PDFs are free and unlimited. No credit card needed.

