Compile your PDF layout once. Generate it offline.
ForkPDF AOT turns an observed HTML/CSS layout into a self-hosted .fpaot bundle.
Generate PDFs offline in Node or a Worker with selectable compliance profiles — no Chromium,
no browser, and no ForkPDF API in the request path.
Two-page invoice
Carried-forward and brought-forward rows, totals, and payment block.
Side-by-side
API reference vs AOT output.
Same payload. The left side is the original API render. The right side is the structurally generated AOT PDF.
API renderAOT bundle
Drag the divider to reveal each version. Both sides use the same five-item payload.
Example corpus
What this example bundle covers.
This preview bundle was compiled from every combination of 18 item counts, project descriptions
at one or two lines, and notes at one or two lines. Every item description and detail stays on one line.
1p one page 2p two pages
Page count for 18 item counts across four project and notes line profiles
Profile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
P1 / N1
1p
1p
1p
1p
1p
1p
1p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
P1 / N2
1p
1p
1p
1p
1p
1p
1p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
P2 / N1
1p
1p
1p
1p
1p
1p
1p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
P2 / N2
1p
1p
1p
1p
1p
1p
1p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
2p
72payloads
72plans
268plates
7.7 MBbundle
72 / 72payload validation
5 / 5Worker PDFs compliant
Declared envelope, validated across all 72 shapes. This is the invoice example,
not a universal coverage claim. Certificates, payslips, tickets, and badges often have smaller
finite variant sets, so they can be compiled exhaustively and covered 100% within their declared envelope.
Example profile: PDF/UA-2 + PDF/A-4
Cloudflare Workers benchmark
Workers Paid, Delhi (DEL), 20 warm-up requests and 100 measured warm requests per shape.
260–425 mswarm PDF-ready p50
full PDF delivery p502.8–3.3 MB example files
1.95 scold request p50
DELmeasured colo
These PDF sizes are for the example bundle compiled with PDF/UA-2 + PDF/A-4.
AOT also supports plain output, PDF/UA-1/2, PDF/A-2/3/4, and combined profiles. The selected
profile is locked per bundle, and these sizes are not a minimum or universal AOT output size.
Shape
Warm PDF-ready p50
Warm PDF-ready p95
Full PDF p50
PDF size (UA-2 + A-4)
1 page · 5 items
269 ms
414 ms
383 ms
2.82 MB
1 page · 7 items
260 ms
447 ms
356 ms
2.82 MB
2 pages · 12 items
378 ms
603 ms
493 ms
3.26 MB
2 pages · 18 items
425 ms
664 ms
547 ms
3.26 MB
Cold isolate
1.95 s TTFB p50 across 10 fresh versions. Every sample reported a cold runtime cache. Bundle load was ~19 ms because the asset was already cached in the colo.
First request after deploy
3.8 s total, including a 1.76 s bundle asset pull and the first-generation lazy plan/plate load.
“PDF-ready” is time to response headers and includes network latency plus generation. Full-PDF time includes
transferring the entire file. These numbers are from one colo, not a global guarantee. Workers Paid is required;
Free’s 10 ms CPU limit is below this workload.
Best-fit use cases
Coverage is per document family, not universal.
AOT coverage is the share of a declared document set that you enumerate, compile, and validate.
Exhaustive AOT
Closed, limited variant sets
Certificates and awards
Payslips and earnings statements
Tickets, passes, and event badges
Fixed-format labels and cards
Compile every variant and AOT can cover 100% of that declared set with zero API calls at runtime. Unseen variants fail closed so the corpus can be extended.
Measured AOT + API fallback
Variable content, measurable mix
Invoices with free-form line items
Statements and reports with variable notes
Customer-specific document packs
Measure a held-out sample from the customer’s actual document mix. Route the covered share to AOT and send misses to the Cloud API.
Not a fit
Unbounded or user-authored layouts
Arbitrary HTML-to-PDF
User-authored templates
Unbounded tables or page designs
Use the Cloud API when the layout itself changes at runtime or the variation set cannot be enumerated.
A “90%” result is only meaningful as 90% of this customer’s measured document mix,
not “90% of all invoices.” A closed certificate or badge program can instead be compiled exhaustively
and reach 100% of its declared set.
Three steps. One compiled file.
You keep using the same HTML, CSS, and layout-check script. AOT changes when and where the PDF is generated.
1
Observe layouts
Render the template across its supported data shapes and capture the pages, text slots, and pagination decisions.
2
Compile
Run fpaot compile. ForkPDF turns those observations into one .fpaot bundle.
Compile runs on your build machine. Plate generation is self-contained: bundled PDF.js and @napi-rs/canvas, with no Inkscape, Poppler, or system fonts required.
3
Generate offline
Load the bundle in Node or a Worker. No Chromium, no browser, and no ForkPDF API request at generation time.
What gets compiled?
ForkPDF keeps observed pages, plates, glyphs, line-break rules, and the template testcase. It does not ship Chromium or call the API at runtime.
Selectable compliance profiles locked per bundle; the example uses PDF/UA-2 + PDF/A-4
Falls back to the Cloud API
19 or more line items
Item details that need a second line
Project descriptions or notes that need 3+ lines
Unobserved layouts
Arbitrary HTML-to-PDF at runtime
Workers Free, because the 10 ms CPU limit is too small
Preview status
APIs and bundle format may change before 1.0.0
A held-out benchmark across general invoice workloads is not yet complete
Compile requires Node.js 22.13+ on the build machine; runtime generation supports Node.js 18+ and Workers. Inkscape, Poppler, and system fonts are not required.
Fail-closed codes are stable enough to route programmatically: E_MISSING_PLAN for an
unobserved item count and E_CONTENT_PROFILE_NOT_FOUND when text needs a taller line profile.
Verification
Designed to be checked, not trusted.
The preview bundle is validated against the rendered corpus and the generated structural output.
The Worker benchmark also downloads real PDFs and checks them with veraPDF, so the numbers and
compliance claim come from the deployed path rather than a local lookup.
A single compiled bundle containing the observed pages, plates, glyphs, and layout rules needed to generate PDFs later.
Plate
A pre-rendered page fragment containing background graphics and text/image slots that the runtime reuses to rebuild an observed page.
Observed layout
A data shape ForkPDF rendered while building the corpus, including item count, line profiles, and page split.
Testcase
Compiled, sandboxed template code that can measure layout, decide pagination, compute values, and apply a final page plan.
data.pb
The spatial layout data that records where text, images, and rows appeared on the page.
Changed input
Different invoice text or values that stay inside an observed line profile. ForkPDF rebuilds the PDF structurally.
Fail closed
If a required layout was never observed, ForkPDF returns a clear error instead of guessing or selecting a nearby layout.
Release 0.3.0-preview.1
What changed in this preview
New
Self-contained plate compilation with bundled PDF.js and @napi-rs/canvas — no Inkscape, Poppler, or system fonts
Selectable compliance: plain, PDF/UA-1/2, PDF/A-2/3/4, and combined profiles, locked per bundle
72-shape invoice example corpus with 1–18 one-line item rows
One-page and two-page structural generation
Cloudflare Workers benchmark with real PDF downloads
Fixed
Single-token text, fixed table cells, and no-wrap totals remain reflowable
PDF 2.0 header preserved after trailing blank-page trimming
Unknown layouts fail closed instead of selecting a nearby plan
Frequently asked questions.
The short version of how AOT works, what it supports, and where it runs.
What is ForkPDF AOT?
ForkPDF AOT compiles observed HTML/CSS layouts into one .fpaot bundle. You can later generate PDFs from that bundle without Chromium, a browser, or a ForkPDF API request.
Does AOT only support PDF/UA-2 + PDF/A-4?
No. PDF/UA-2 + PDF/A-4 is the profile used by the invoice example. The compiler supports plain output, PDF/UA-1/2, PDF/A-2/3/4, and combined profiles. The selected profile is locked to the bundle, so runtime requests cannot silently downgrade or switch policy.
Which invoice layouts are supported?
The preview bundle covers 1–18 invoice items, one-line item descriptions and details, and project descriptions and notes at one or two lines. It generates one-page and two-page layouts. Unsupported layouts fail closed so the caller can use the Cloud API.
Can AOT cover 100% of a document type?
Yes, for a closed variant set that you enumerate and compile. AOT can cover 100% of the declared variants with no API calls at runtime. For open-ended document families, measure coverage against a held-out customer sample and route misses to the Cloud API. There is no universal coverage percentage.
Which Cloudflare plan is required?
Workers Paid is required. Structural generation uses roughly 150–315 ms CPU when warm and about 1.6–1.9 seconds CPU on a cold request, well above the Free plan’s 10 ms CPU limit.
Is ForkPDF AOT stable?
No. AOT is a preview feature. The package, bundle format, and APIs may change before the first stable 1.0.0 release.
Preview
Start with a compiled bundle.
Inspect the invoice example and edge numbers, then compile your own template and declare its supported envelope.