HTML-to-PDF example library

A curated set of eight complete HTML-to-PDF examples, each with a Nunjucks template, data payloads, an independent test case, a render script, generated PDFs, previews, and its own documentation.

The collection covers the document types that usually break in production: long invoices, contract packets, fillable forms, exact-size shipping labels, and accessible annual reports. Every example installs and renders on its own against the Fork PDF API, and the full source is on GitLab under the MIT license.

8complete examples
5document families
MITlicensed source
Two formats: the eight cards below are full GitLab repositories with source, tests, and generated output. The Q3 report, travel itinerary, and self-healing invoice are hosted walkthroughs with source zips on this site. GitLab is the canonical source for every repository example, including future additions.
AOT preview: the same Atelier invoice is also compiled into one self-hosted file for offline generation. New bundles rebuild every payload structurally from observed plans, text-stripped plates, and a locked text runtime; changed strings reflow within compiled content profiles. Unseen layouts are refused instead of guessed. PDF/UA and PDF/A output is available when the bundle is compiled with that profile. See the AOT showcase or inspect the verification repo ↗.

Quick start

Clone the repository and render any example with your Fork PDF API key and project ID.

git clone https://gitlab.com/fork-pdf/examples.git
cd examples/invoices/freelance/01-atelier
npm install
cp .env.example .env
# Add FORKPDF_API_KEY and FORKPDF_PROJECT_ID to .env
set -a && . ./.env && set +a
npm run render

Each example follows the same pattern. To verify every example without rendering PDFs or consuming API credits, run npm run examples:verify at the repository root.

Invoice examples

Four invoice layouts, each built around a different billing model and a measured pagination problem.

Atelier freelance invoice with an editorial layout and measured line-item table
Freelance invoice GitLab repository

Atelier

Editorial invoice with measured line-item pagination, carried-forward totals, and a payment QR block.

  • Measured table pagination
  • Carried-forward totals
  • Local fonts and fixed slots
Fieldwork agency retainer invoice with a bold orange grid and time entries
Agency retainer invoice GitLab repository

Fieldwork

Retainer drawdown and time-entry billing with a bold signal-orange grid and a compact summary.

  • Retainer drawdown
  • Time entries and totals
  • High-contrast grid layout
Northstar SaaS subscription invoice with usage billing and VAT rows
SaaS subscription invoice GitLab repository

Northstar

Usage billing with credits, VAT, and paid, due, and overdue states in one template.

  • Usage and credit lines
  • VAT and totals
  • Paid, due, and overdue states
Ironline construction application for payment with a schedule of values
Construction application GitLab repository

Ironline

Schedule of values, retainage, change orders, and a certification page for progress billing.

  • Schedule of values
  • Retainage and change orders
  • Certification and signature

Contracts, forms, labels, and reports

Four more document families that test pagination, AcroForm fields, exact physical dimensions, and accessibility metadata.

Ardent contract packet cover page with NDA, MSA, and SOW sections
Contract packet GitLab repository

Ardent

NDA, MSA, and SOW in one packet with measured prose pagination, a TOC, an execution page, and signature geometry.

  • Measured prose pagination
  • TOC and execution page
  • Signature coordinates
Meridian fillable contractor form with native AcroForm fields
Fillable form GitLab repository

Meridian

Native AcroForm controls generated from HTML, with 73 mapped fields, a signature overlay, and field-map JSON.

  • 73 mapped AcroForm fields
  • Signature overlay box
  • Field-map JSON
Northline 100 by 150 millimetre shipping label with a Code 128 barcode
Shipping label GitLab repository

Northline

Exact 100 × 150 mm output with a locally generated Code 128 barcode and scanner quiet-zone validation.

  • Exact physical dimensions
  • Code 128 barcode
  • Quiet-zone validation
Aurora annual report cover with PDF/A-4 and PDF/UA-2 output
Accessible report GitLab repository

Aurora

Annual report with PDF/A-4 and PDF/UA-2 output, charts, TOC targets, and 15 tagged tables.

  • PDF/A-4 + PDF/UA-2
  • Charts and TOC targets
  • 15 tagged tables

Why these examples are different

HTML-to-PDF rendering is table stakes. These examples focus on the problems that actually break production documents:

  • Measured pagination. Invoices and contracts measure rendered content and repair page plans with data patches. Typography and spacing stay unchanged.
  • Geometry from the test case. Contract signatures, form fields, label barcodes, and report sections return coordinates through testResults — no data.pb parsing required.
  • Fillable PDF forms. Standard HTML controls become tagged AcroForm fields, with a separate overlay box for signatures.
  • Exact physical output. Shipping labels use custom page dimensions, locally generated Code 128 barcodes, image-loaded checks, and scanner quiet zones.
  • Accessible mixed media. Aurora combines PDF/A-4, PDF/UA-2, chart images, TOC targets, scoped table headers, and running headers.
  • Self-contained examples. Every folder installs and renders on its own with user-provided Fork PDF credentials.

What every example includes

  • A Nunjucks template and multiple data payloads.
  • A stylesheet with local fonts and reserved image boxes.
  • An independent test case and a render script.
  • Generated PDFs, preview images, and geometry or report JSON.
  • Documentation for the layout, the checks, and the output.
Security: no API keys, customer data, or .pb files are committed. Credentials come from FORKPDF_API_KEY and FORKPDF_PROJECT_ID in your environment.

Hosted walkthroughs

Hosted walkthrough These API-focused tutorials live on forkpdf.com and pair well with the repository examples:

  • Q3 report — auto-generated TOC, chart and commentary healing, and signature coordinates.
  • Travel itinerary — five spatial checks and two dependent patches.
  • Invoice self-healing — table overflow, Tier 1 patches, and a Tier 2 webhook fallback.

Browse the full collection

Every example includes its own README, render script, test case, and generated output. GitLab remains the source of truth as the collection grows.

Open the Fork PDF examples on GitLab ↗