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
2. Check each stage of the upload
| Stage | What to check |
|---|---|
| Select | The chosen name and size are visible, and removing or replacing the selection works. |
| Send | The progress state ends, a failure explains how to retry, and repeat clicks do not create unwanted duplicates. |
| Store | The expected record and file exist after a success. Rejected files do not leave usable document records. |
| Preview | The first and last pages show content. Reloading or returning to the page still opens the correct document. |
| Download | The 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
- Open the downloaded document in a PDF reader. If it opens there, investigate the embedded viewer and the browser environment separately.
- Check the response status and Content-Type. An HTML error page can still appear in an iframe, so its load event is not evidence of a valid PDF.
- Try a direct document link if your application offers one. A viewer or browser policy may affect embedded documents differently.
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.