Lorixen.
EN

Generating PDF quotes and certificates from your web app

Short answer: Treat the PDF as its own small product inside the web app and specify it properly: who owns and edits the template, how long tables break across pages, which fonts carry te reo Māori macrons, how documents are numbered, whether the issued file is stored or regenerated, and how it reaches the customer. Most small-business apps build PDFs by rendering an HTML template in a headless browser; a PDF library suits fixed layouts such as certificates, and a hosted document service suits teams that want non-developers to edit templates.

A quote, a training certificate, a job report: the PDF is often the only part of your app a customer keeps. It gets printed, forwarded and opened on phones months later. If it breaks a table across pages badly, shows a box where "Tāmaki" should be, or comes out differently each time someone downloads it, customers notice. The brief below is organised in the order a developer needs the decisions.

1. Purpose and document types

List every document the app produces and what each is for.

Document Triggered by Who receives it Changes after issue?
Quote Staff press "Send quote" Customer New version if revised
Certificate of completion Course marked complete Learner (and employer) Never
Job report Technician closes job Customer, office Rarely

Decide this: Which documents exist in version one, and which can wait. Each document type is a template to design, test and maintain.

2. Template ownership and editing

The biggest long-term cost is not generating the PDF; it's changing the layout later. Options:

  • Developer-owned HTML template: cheapest to build. Every wording or logo change is a developer task.
  • Editable sections: the layout is fixed, but staff can edit text blocks (terms, footer, signature line) in the app's settings.
  • Hosted document service with a visual editor: non-developers change templates; you add a dependency and usually a subscription.

Decide this: Who changes the wording of your terms or the logo next year, and how quickly. Write down which text blocks staff must be able to edit without a developer.

3. Page size, layout and page breaks

Specify A4 portrait (or landscape for certificates) and margins. If the PDF is generated from HTML, CSS controls the print layout. MDN documents the @page rule for page size, margins and margin boxes such as @top-right for page numbers, and the break-inside: avoid property to stop a box being split across pages (as of November 2026). With Playwright's page.pdf(), for example, the documentation notes it uses print CSS media by default, supports formats including A4, has a preferCSSPageSize option so your CSS @page size wins, and offers header and footer templates with page number and total pages.

Long tables are where PDFs usually fail. Ask for:

  • Table header rows repeated on every page
  • No row split across two pages
  • Totals block kept together with the last rows
  • A test document with 3 lines, 30 lines and 300 lines

Decide this: What the longest realistic quote looks like. Hand the developer a real example (with customer details changed) to test against.

4. Fonts, macrons and special characters

New Zealand documents carry place names, people's names and words in te reo Māori. A font that lacks ā, ē, ī, ō or ū will show a missing-glyph box or fall back to a different typeface mid-word.

  • Choose a font that includes macrons in every weight you use (regular, bold, italic).
  • Embed the font in the PDF rather than relying on the reader's device. Libraries differ here: pdf-lib's documentation, for instance, says the @pdf-lib/fontkit module must be installed to embed custom fonts.
  • Test with a sentence containing every macron vowel in upper and lower case, plus your own customers' names with apostrophes and hyphens.
  • Check copy-and-paste from the PDF: text copied out should keep its macrons.

Decide this: The font family, and a test string that every template must render correctly before go-live.

5. Numbering and versioning

Quotes and certificates need numbers people can quote back to you.

  • Format: prefix plus sequence (Q-2026-0142, CERT-00318). Avoid numbers that reveal how few you've issued if that matters to you.
  • Who assigns it: the database, once, at the moment of issue, never the PDF generator.
  • Revisions: a revised quote gets Q-2026-0142 v2, not a new number, so the history stays together.

Decide this: The number format, when a number is assigned (draft or issue), and how revisions are labelled.

6. Store the issued PDF, or regenerate it?

This decision catches many projects out.

Store the issued file Regenerate on demand
What the customer sees later Exactly what they were sent Whatever the current template and data produce
Template changes Don't affect old documents Silently change old documents
Storage Grows over time Minimal
Best for Quotes, certificates, anything someone may dispute Internal reports, draft previews

For anything customer-facing, store the file at issue time and keep a record of what was sent and when. Regenerate only drafts and previews.

Decide this: Which documents are stored, where (your app's file storage or a cloud bucket), and for how long. If long-term archiving matters, ask your developer whether an archival PDF format is worth it.

  • Email the PDF as an attachment, a secure link, or both. Links are easier to revoke and track; attachments survive the customer's inbox search.
  • Name files usefully: Quote-Q-2026-0142-Smith.pdf, not document(3).pdf.
  • Give staff a "resend" button that sends the stored file, not a fresh one.
  • For certificates, consider a short verification page where an employer can check a certificate number is genuine.

Decide this: Attachment, link or both; who can download a document; and whether certificates need a public check page.

8. Accessibility and metadata

PDFs can carry structure that screen readers use. Playwright's page.pdf() documentation lists a tagged option to generate a tagged (accessible) PDF and an outline option for a document outline, both defaulting to off. pdf-lib's documentation includes setting document metadata such as title and author.

Decide this: Whether documents must be tagged, and what title metadata each file gets.

Choosing the generation approach

  • HTML template in a headless browser (for example Playwright or Puppeteer): reuses your web styling and handles long, flowing content well. Needs a server that can run a browser.
  • PDF library (for example pdf-lib): draws text and images at exact positions and can fill existing PDF forms. Suits certificates with fixed layouts; fiddly for long tables.
  • Hosted document service: template editor and API; good when non-developers own templates. Check data location, limits and pricing on the provider's own pages.

FAQ

Can't we just use the browser's "Print to PDF"?

For internal one-offs, yes. For documents the app sends automatically, you need server-side generation so the output is the same every time.

Why does our PDF look different from the web page?

Print CSS and screen CSS differ, and some generators print with print media by default. Design the PDF template for print from the start.

How do we add a signature image to certificates?

Store the image securely and place it in the template like any other image; restrict who can change it. Electronic signing workflows are a separate project.

How long should generating a PDF take?

Usually a few seconds at most for one document. If staff generate hundreds at once (end-of-course certificates), ask for background processing with a notification when the batch is ready.

PDF output is easy to underestimate in a web app brief, and we're glad to help you spell out yours before the build starts.

Sources

WhatsAppLet’s talk