Skip to content

PRACTICAL GUIDES

Test a PDF upload from selection to preview

A practical checklist for file-size limits, multi-page viewers, retry behavior and repeatable PDF fixtures.

An upload button can accept a file even when the document cannot be previewed or stored correctly. Separate those steps when testing. Start with a small known PDF, then change one property at a time so a failure has an identifiable cause.

1. Keep a small, known document

Use the PDF generator with one page and the title Upload test. Save the file with a descriptive name. Confirm that your own PDF reader can open it before using it in the upload flow. The API form below creates a small document; it does not set a target file size.

curl --fail 'https://anyplaceholder.com/api/pdf?pages=1&title=Upload%20test'   --output upload-test.pdf

Open the PDF generator →

2. Check each stage of the upload

StageWhat to check
SelectThe chosen name and size are visible, and removing or replacing the selection works.
SendThe progress state ends, a failure explains how to retry, and repeat clicks do not create unwanted duplicates.
StoreThe expected record and file exist after a success. Rejected files do not leave usable document records.
PreviewThe first and last pages show content. Reloading or returning to the page still opens the correct document.
DownloadThe saved file opens and has the expected number of pages. A download-link click alone is not proof of a saved file.

3. Test the exact size boundary

First establish whether the limit is decimal MB or binary MiB. For a 5 MB limit, use 4,999,999, 5,000,000 and 5,000,001 bytes. For 5 MiB, use 5,242,879, 5,242,880 and 5,242,881 bytes. Decide whether the limit is inclusive, then check that the interface and server enforce the same rule.

Create exact-size test files →

4. Separate page count from file size

A 20-page text-only PDF can be much smaller than a single scanned page. Use 1, 3 and 20 pages to test pagination, page navigation and thumbnails. Use the size generator for byte limits. Do not assume a padded PDF exercises image decoding or OCR: those need real synthetic image fixtures.

5. When the preview is blank

Keep the fixture with the test

Store the file, exact byte count, page count and expected result with the test case. Use a local fixture for automated tests that must not depend on a public service. Avoid putting customer documents or personal information in a reproduction case.