.pdf

PDF test files

PDFs written byte by byte: clean multi-page documents, password-protected files, and files broken in one specific way so you can test repair and error handling.

Or start from a preset

What is a PDF file?

Short answer

A PDF file is a set of numbered objects (pages, fonts, content streams) plus a cross-reference table that gives the byte offset of each object, and a trailer that points at the document catalog. Readers jump to the end, read the xref, then load what they need.

Because everything hangs on byte offsets, small faults have big effects: an xref off by a few bytes, a missing %%EOF, a truncated download or a corrupt compressed stream. Each damage option breaks exactly one of these, so you know what your reader is recovering from.

Anatomy of a PDF file

  • %PDF-1.4The header and version
  • 1 0 obj … endobjNumbered objects: catalog, pages, fonts, streams
  • stream … endstreamPage content, optionally Flate-compressed
  • xrefByte offset of every object
  • trailerSize, root, info, file ID and encryption
  • startxref / %%EOFWhere the xref starts, and the end marker

What you can generate

  • 1 to 1,000 pages of Helvetica text, A4, US Letter or A5
  • Bookmarks (outline), links, a rotated page and mixed page sizes
  • Accented WinAnsi text and strings with ( ) and \ escaped
  • Flate-compressed or plain content streams
  • Password protection: RC4 128-bit, password test
  • Broken on purpose: missing xref, wrong xref offsets, truncated at 60%, corrupt content stream, missing %%EOF

How to make one

  1. Open the PDF generator, or start from a preset above.
  2. Set the size and switch on the edge cases you need; the preview and size estimate follow every change.
  3. Generate, then download. The file is made in your browser, and the same preset and seed always give you the same file.

Questions

Yes. Every xref offset points at its object, and the tests open each file with pdf.js and read the page count, text and bookmarks.

With the standard security handler, revision 3: RC4 with a 128-bit key. The user password is test. pdf.js refuses it without the password and opens it with it. AES encryption is on the list for later.

Missing xref drops the table, wrong offsets shifts every entry by 13 bytes, truncated cuts the file at 60%, corrupt stream overwrites the start of page 1's compressed content, and missing %%EOF removes the end marker.

The standard Helvetica and Helvetica-Bold fonts with WinAnsi encoding, which every reader has, so no font is embedded.

Related formats