PDF Generation API

Generate PDF documents from reusable templates and JSON data. Design templates with our drag-and-drop editor or with HTML and CSS, then create pixel-perfect PDFs at any volume. Generate invoices, contracts, certificates, reports, and more.

Start Free Trial

Generate a PDF with one API request

POST your JSON data to a template and get back a download URL for the finished PDF.

# frozen_string_literal: true

require 'docspring'

client = DocSpring::Client.new
response = client.generate_pdf(
  template_id: 'YOUR_TEMPLATE_ID',
  test: true,
  data: { first_name: 'John', last_name: 'Smith' },
  metadata: { user_id: 123 }
)
puts "Download your PDF at: #{response.submission.download_url}"

Read the API documentation

Two ways to design your documents

Start from a PDF

Upload any PDF, such as a government form, a contract, or your own design, and place fields visually with the drag-and-drop template editor. Fillable form fields are imported automatically.

Or build with HTML & CSS

Design fully custom documents with HTML, CSS, and Liquid, using variables, loops, and conditions for dynamic invoices and reports.

Rich field types

Text, dates, checkboxes, images, signatures, barcodes, and QR codes. Generate anything from filled tax forms to shipping labels.

Any volume

Synchronous single requests, batches of up to 50 PDFs, or asynchronous generation with webhooks. Free, unlimited test mode with watermarked PDFs.

PDF Generation API FAQ

What is a PDF generation API?

A PDF generation API creates PDF documents programmatically from templates and data. With DocSpring, you design a template once, then send a POST request with JSON data whenever your application needs a PDF, such as invoices, contracts, certificates, or reports.

How do I design my PDF templates?

Two ways: upload an existing PDF and place fields with our drag-and-drop template editor, or build templates from scratch with HTML, CSS, and the Liquid templating language for fully custom layouts.

What field types are supported?

Text, numbers, dates, checkboxes, radio buttons, images, signatures, barcodes, and QR codes. You can generate anything from filled government forms to shipping labels.

How many PDFs can I generate?

Generate a single PDF synchronously in one request, batch-generate up to 50 PDFs per request, or use the asynchronous API with webhooks for high-volume workloads. Test mode is free and unlimited.

Is DocSpring secure enough for regulated documents?

DocSpring is SOC 2 Type 2 certified and GDPR compliant, with US, EU, and AU data residency and BAAs available. Self-hosted enterprise licenses are available too.

Start generating PDFs in minutes, not weeks

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