PRACTICAL GUIDE / test cases for PDF generation

Test Cases for PDF Generation: Reports and Invoices QA

Test cases for PDF generation covering layout, data accuracy, pagination, fonts, downloads, permissions, invoices, print, and accessibility.

By The Testing AcademyUpdated July 10, 20268 min read
All field guides
In this guide9 sections
  1. Establish the Document Oracle
  2. Build Data That Stresses the Template
  3. Verify Data, Calculations, and Formatting
  4. Challenge Pagination and Repeating Elements
  5. Test Fonts, Images, and Rendering Engines
  6. Validate Download, Storage, and Regeneration
  7. Enforce Authorization and Content Safety
  8. Check Accessibility and Print Output
  9. Combine Structural Automation With Visual Review

What you will learn

  • Establish the Document Oracle
  • Build Data That Stresses the Template
  • Verify Data, Calculations, and Formatting
  • Challenge Pagination and Repeating Elements

An invoice PDF can look polished while showing a total that differs from the order by one rounding step. It can also place the correct total under the wrong customer's name because generation used stale or unauthorized data. Visual approval alone cannot establish that a generated document is accurate, private, printable, and usable by assistive technology.

Treat the PDF as a durable business artifact. Its test oracle combines source data, calculation rules, layout, document structure, delivery, and access control. Define which values are snapshots at generation time and which may change when the document is regenerated.

Establish the Document Oracle

List every source field, transformation, and presentation rule. For an invoice, include seller and buyer identity, tax identifiers, line descriptions, quantity, unit price, discount, tax, subtotal, total, currency, dates, payment status, and document number. For a report, include filter criteria, time zone, sort order, grouping, and aggregate formulas.

Use an independent expected dataset rather than copying values out of the generated document. Calculate totals with the approved precision and rounding policy. Record whether the PDF should preserve historical names and prices even if the source record changes later.

Oracle layerExample assertion
Business dataCorrect customer, lines, amounts, and status
PresentationLabels, formats, branding, and page structure
PDF structurePages, metadata, fonts, links, tags
DeliveryFilename, content type, complete download
SecurityOnly authorized user can generate or retrieve

Build Data That Stresses the Template

Generate the smallest valid document, a typical one, and a maximum realistic one. Include no optional address, a complete international address, very long customer and product names, long unbroken identifiers, multiline notes, zero and negative adjustments where valid, many decimal places at input, and multiple currencies or scripts supported by the product.

Place a table row exactly at a page boundary, then add one more line. Include a section with no records, one record, and enough records for several pages. Add images at expected limits, missing images, unusual aspect ratios, and transparent backgrounds.

Use deterministic dates, locale, time zone, and fonts in automated environments. Otherwise harmless machine differences create noisy snapshots and hide real changes.

Verify Data, Calculations, and Formatting

Compare extracted text and structured values with the independent expected dataset. Check that every line appears once and belongs to the intended record. Confirm subtotals, discounts, tax bases, tax amounts, shipping, payments, refunds, and final balance use the same rules as the source transaction.

Test locale-specific decimal and grouping separators, currency symbol placement, negative numbers, date format, address order, and translated labels. The underlying number must not change when presentation changes. A zero amount should follow the business wording, not disappear because it is falsy.

For reports, verify filters and sort order are printed so a reader knows the document's scope. Compare totals across page breaks and grouped sections. Empty reports should explain that no records matched rather than generating a blank or corrupt file.

Challenge Pagination and Repeating Elements

Inspect content immediately before and after every page break. Rows should not overlap footers, split illegibly, disappear, or repeat. If rows may split, headers and context must make the continuation understandable. Table headers should repeat on later pages when the template promises it.

Check page numbers, total page count, running headers, footers, legal text, watermarks, and signatures on one-page and multi-page documents. The last page often exposes different spacing because the footer or totals section changes.

BoundaryFailure to look for
First row on new pageMissing header or excessive gap
Long cell across pagesClipped or duplicated text
Totals after long tableDetached labels or hidden amount
Image near page endOverlap, blank page, wrong scaling
Exact full pageUnexpected trailing blank page

Test Fonts, Images, and Rendering Engines

Confirm required fonts are embedded or replaced by an approved fallback. Exercise accented Latin, Arabic or Hebrew if supported, Indic scripts, CJK text, emoji policy, and mixed-direction content. Missing glyphs may appear as boxes in one viewer while looking correct in another.

Open representative files in the browsers and desktop or mobile readers the product supports. Zoom in and out, search text, copy text, follow links, and inspect image quality. Text that was accidentally converted to a low-resolution image may look acceptable at fit-to-page but fail search and accessibility.

Test missing logo or image service, corrupt image data, and slow asset retrieval. Generation should use a defined fallback or fail clearly, not produce a half-rendered official document without warning.

Validate Download, Storage, and Regeneration

Check response status, application/pdf content type, content length where used, and a meaningful sanitized filename. Interrupted downloads should fail visibly rather than save a truncated file that appears complete. Repeated clicks must not create uncontrolled duplicate jobs.

For asynchronous generation, test queued, running, completed, failed, expired, and cancelled states. Refresh and return later. The completion link should reference the requested parameters and user, and a failed job should be retryable without changing business data unexpectedly.

Define whether regeneration returns the original snapshot or a new version. Change source data between generations and verify the policy. Stored files need retention, deletion, and cache invalidation rules so an old private document does not remain available after access is revoked.

Version the template and rendering dependencies in test evidence. Regenerate the same frozen dataset before and after a template deployment, then classify every difference as intentional content, layout, metadata, or rendering noise. If legal documents must remain reproducible, retain the template version and assets used for the original. If the policy instead always renders current branding, show the generation date and avoid presenting a regenerated file as the historical original.

Test two simultaneous generation requests for the same record. The system may return one shared immutable artifact or two equivalent files, but it should not mix temporary assets, overwrite another tenant's output, or expose a partially written object. Cleanup jobs must avoid deleting a file while an authorized download is in progress.

Enforce Authorization and Content Safety

Attempt to generate and download another user's document by changing IDs, filenames, object-store keys, job IDs, and signed URLs. Authorization must run on every route, including previews and historical versions. A guessed URL should not reveal whether a document exists.

Verify signed-link expiry and behavior after logout, role removal, or tenant change. Public caching must not store personalized documents. Logs and analytics should avoid document contents, access tokens, and sensitive query parameters.

If PDFs are encrypted or digitally signed, test the intended permissions, password failure, certificate identity, signature validity, and visible result after any content modification. Expired or rotated signing certificates need an operational policy that preserves trust in historical documents while ensuring new files use the current approved credential.

Insert markup-like text, control characters, external image URLs, and unexpected long values through approved test data. The generator must treat user content as data and must not fetch arbitrary internal addresses or execute active content. Document metadata should not expose server paths, template usernames, or internal software details unnecessarily.

Check Accessibility and Print Output

For accessible PDFs, inspect title, language, tagged reading order, heading hierarchy, table headers, link purpose, alternative text, and form labels where present. Decorative images should not create noise. Visual order and tagged order need to agree, especially in columns and repeated tables.

Navigate with a screen reader and keyboard in a supported reader. Select and copy text to check reading sequence. Use an automated accessibility checker as a detector, then manually inspect meaningful order and descriptions.

Print to supported paper sizes in color and grayscale. Confirm margins, scaling, page breaks, contrast, barcodes or QR codes, signatures, and cut-off risk. A browser print preview of the source page is not evidence that the downloaded PDF prints correctly.

Combine Structural Automation With Visual Review

Automate file signature, page count, metadata policy, extracted text, key values, links, and selected PDF-structure checks. Compare images only for controlled templates and mask dynamic fields such as timestamps or identifiers. Pixel snapshots are sensitive to fonts and rendering versions, so keep the environment pinned and require human review for intentional design changes.

Retain a small golden set: one minimal file, one typical invoice or report, one multilingual file, one page-boundary case, one large document, and one access-denied case. Review visual output in at least two rendering engines when compatibility matters.

Keep one document as a traceable audit artifact. Follow it from source record through calculation, generation, download, reopen, print, and later retrieval, comparing identity and totals at every step. This artifact joins business and rendering evidence in a way that neither a database assertion nor a screenshot can provide alone.

// FIELD DISPATCH

Get the QA Field Notes

Weekly QA battles, AI testing guides, and interview drills. Free on Substack.

The Testing Academy editorial desk

Practical QA guidance built around test evidence, production tradeoffs, and interview-ready explanations.

Published July 10, 2026 / Reviewed July 10, 2026

PRIMARY REFERENCES

Verify the details at the source

QABattle guides are practical explanations. Product behavior, standards, and APIs can change, so use these primary references for the canonical details.

  1. 01
    ISTQB glossary

    ISTQB

    Shared testing terminology for test design, defects, levels, and lifecycle concepts.

FAQ / QUICK ANSWERS

Questions testers ask

What is the correct oracle for an invoice PDF?

Compare it with an independent expected dataset and approved rounding rules, not values copied back from the document. Verify customer identity, every line exactly once, tax bases, discounts, totals, currency, and status. Then add presentation, PDF structure, delivery, authorization, and historical snapshot assertions as separate oracle layers.

Which data best exposes PDF pagination defects?

Place a table row exactly at a page boundary, then add one more line and include a long cell that may split. Inspect repeated headers, rows before and after the break, totals placement, footers, page count, and trailing blank pages. Repeat with missing and unusual-aspect images near the boundary.

How should private PDF download authorization be challenged?

Change record IDs, filenames, object keys, generation job IDs, preview routes, historical versions, and signed URLs. Every route must recheck current user and tenant permission without revealing document existence. Also verify expiry, logout, role removal, cache controls, simultaneous generation, and that temporary files never cross tenant boundaries.

Should regenerating a PDF reproduce the original or use current data?

Choose and document one policy. A historical business artifact may need the original source snapshot, template version, fonts, and assets, while another product may intentionally render current branding or data. Change the source between generations and verify version labeling, cache invalidation, retention, and whether the regenerated document is represented honestly.

Why are both structural automation and visual review needed for PDFs?

Extracted text and metadata can prove values, links, page count, tags, and file integrity, but they may miss clipping or overlap. Pixel comparison catches layout changes but is sensitive to fonts and renderers and cannot prove reading order or calculations. Use controlled golden files plus manual accessibility, print, and cross-reader review.