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.
In this guide9 sections
- Establish the Document Oracle
- Build Data That Stresses the Template
- Verify Data, Calculations, and Formatting
- Challenge Pagination and Repeating Elements
- Test Fonts, Images, and Rendering Engines
- Validate Download, Storage, and Regeneration
- Enforce Authorization and Content Safety
- Check Accessibility and Print Output
- 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 layer | Example assertion |
|---|---|
| Business data | Correct customer, lines, amounts, and status |
| Presentation | Labels, formats, branding, and page structure |
| PDF structure | Pages, metadata, fonts, links, tags |
| Delivery | Filename, content type, complete download |
| Security | Only 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.
| Boundary | Failure to look for |
|---|---|
| First row on new page | Missing header or excessive gap |
| Long cell across pages | Clipped or duplicated text |
| Totals after long table | Detached labels or hidden amount |
| Image near page end | Overlap, blank page, wrong scaling |
| Exact full page | Unexpected 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.
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.
- 01ISTQB 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.
RELATED GUIDES
Continue the learning route
GUIDE 01
Test Cases for File Upload
Write test cases for file upload covering file types, size limits, viruses, progress, drag-and-drop, security, and accessibility with examples.
GUIDE 02
Test Cases for API Endpoint: REST QA Checklist
Test cases for API endpoint QA covering methods, payloads, auth, status codes, schema, pagination, errors, idempotency, logs, and safe failures.
GUIDE 03
Bug Report Template: How to Write a Great Defect Report
Learn how to write a bug report with a clear template, steps to reproduce, severity vs priority, expected vs actual results, and examples developers trust.
GUIDE 04
Accessibility Testing Checklist (WCAG 2.2)
Use this WCAG accessibility testing checklist for WCAG 2.2 AA: audit process, A vs AA vs AAA, functional test cases, and a practical QA starting path.