Introduction
This is PDF as Adobe defined it from 1993 to 2001, versions 1.0 to 1.4, the files written by Acrobat 1.0 to 5.0 and by the many programs that wrote PDF in those years. A PDF holds fixed pages of text, vector graphics and images, with the fonts it needs, and from later versions in this range also links, forms, annotations, signatures, attachments and transparency. Adobe documented each version in its PDF Reference, and today ISO 32000 covers them too. Documents are made and read with Adobe Acrobat and many other programs.
In these versions every object stands alone in the file, written as text with its
own obj and endobj, and the file ends with a plain-text
cross-reference table that gives the offset of each one. PDF 1.5 changed that: its
objects can be packed inside compressed object streams and indexed by a binary
cross-reference stream, so a reader has to find them differently. Here a version
that only adds stays in the same format, and one that changes how existing
structures are stored starts a new one, so 1.0 to 1.4 are one format and 1.5 to 2.0
another. The encryption of these versions is RC4.
A .pdf file dropped on any page opens in the explorer, which shows its
objects, the cross-reference table and trailer, the page tree, and the decoded
streams, with fonts, images and other embedded files opening in their own viewers.
It does not draw the pages.
Structure
A file is a header line, a body of numbered objects, the cross-reference table and
the trailer. A reader starts at the end: startxref gives the table’s
offset, the table gives every object’s, and the trailer names the catalog, from
which the pages are found.
0Header%PDF-1.0to%PDF-1.4, and a binary commenttwo lines…Body indirect objects: the catalog, pages, content streams, fonts, imagesmost of the file…Cross-reference tablexref, then a 20-byte entry for every object20 bytes an object…TrailerSize,Root,Info,ID,Encrypt; thenstartxrefand%%EOFa few lines
A real file
The start of a small PDF 1.3 file: the header, a comment of bytes above 127, and object 4, a page’s Flate-compressed content.
00000000 25 50 44 46 2D 31 2E 33 0A 25 C4 E5 F2 E5 EB A7 %PDF-1.3.%......
00000010 F3 A0 D0 C4 C6 0A 34 20 30 20 6F 62 6A 0A 3C 3C ......4 0 obj.<<
00000020 20 2F 4C 65 6E 67 74 68 20 35 20 30 20 52 20 2F /Length 5 0 R /
%PDF-1.3, then object 4 at offset 22, as its cross-reference entry 0000000022 00000 n saysFrom the trailer to a page
The trailer’s Root is the catalog,
whose Pages is the root of the page
tree. Each page has a MediaBox, its Resources (fonts,
images, colour spaces) and its Contents, a
content stream of
drawing operators such as 72 700 Td (Hello) Tj.
Reference pages
- File structure – the header, binary comment, body, table, trailer,
%%EOFand incremental updates - Objects and syntax – the eight object types, strings, names, indirect objects and references, text strings and dates
- Streams and filters – the stream dictionary, the eight filters of these versions and the predictors
- Cross-reference and trailer – subsections, 20-byte entries, the free list, the trailer’s keys and the
Prevchain - Document structure – the catalog, page tree, pages, resources, name and number trees, outlines, destinations and logical structure
- Content streams – all 73 operators with their operands and the version that added each
- Graphics – coordinate spaces, colour spaces, patterns, shadings, functions, graphics state and transparency
- Fonts – Type 1, TrueType, Type 3, Type 0 and CIDFonts, encodings, CMaps, ToUnicode, descriptors and embedding
- Images – image XObjects, sample data, Decode arrays, masks and inline images
- Interactive features – annotations, actions, JavaScript, forms, signatures and embedded files
- Metadata – the document information dictionary and XMP metadata streams
- Encryption – RC4, the standard security handler revisions 2 and 3, permissions and public-key handlers
- Linearization – fast web view: the parameter dictionary, the order of parts and the hint tables
- Versions – what 1.0, 1.1, 1.2, 1.3 and 1.4 each added
Telling it apart
A PDF starts with %PDF- (25 50 44 46 2D) and a version.
A file is in this format when its header says 1.0 to 1.4 and every
cross-reference section in it is a plain xref table: no
startxref or Prev leads to a cross-reference stream, the
trailer has no XRefStm, and no object is an object stream
(/Type /ObjStm).
The header alone does not settle it. A file whose header says 1.4 but which has a
cross-reference stream, as some programs write after updating an old file, is a
PDF 1.5 to 2.0 file, and a reader that only knows this format cannot find all of
its objects. A file whose header says 1.5 or later is that format too, even if it
uses only a plain table. The catalog’s Version entry, from PDF 1.4,
can also raise the version above the header’s.
Some files with other extensions are PDF inside. Adobe Illustrator’s
.ai files from Illustrator 9 on are PDF files that also carry
Illustrator’s own data, and open in a PDF reader as their artwork.
Variants
- Portable Document Format, PDF 1.0 to 1.4 – objects at their own offsets, indexed by a plain-text cross-reference table; RC4 encryption
- Portable Document Format, PDF 1.5 to 2.0 – objects can be packed in object streams and indexed by cross-reference streams; AES encryption
Links
Software
- Adobe Acrobat Reader – Adobe’s free PDF viewer, with forms and comments (Windows, macOS, mobile)
- PDF.js – the viewer built into Firefox (web browsers)
- SumatraPDF – small, fast free viewer (Windows)
- Okular – KDE’s document viewer (Linux, Windows)
- Ghostscript – interpreter that renders, converts and compresses PDF (Windows, macOS, Linux)
- qpdf – command-line tool that shows a file’s structure, decrypts and repairs PDF, and can write the QDF form for reading by hand (Windows, macOS, Linux)
Developers
- PDF.js – library that parses and renders PDF (JavaScript)
- pypdf – library that reads, splits, merges and writes PDF (Python)
- Apache PDFBox – library for reading and creating PDF (Java)
- qpdf – library for inspecting and rewriting PDF structure (C++)
- MuPDF – library and viewer for rendering PDF (C)
Reference
- PDF Reference 1.0 – Adobe’s first description of the format, 1993 (PDF)
- PDF Reference 1.2 – the version of Acrobat 3.0 (PDF)
- PDF Reference, second edition – PDF 1.3 (PDF)
- PDF Reference, third edition – PDF 1.4 (PDF)
- ISO 32000-1:2008 – PDF 1.7 as an ISO standard, which also covers everything in 1.0 to 1.4, in Adobe’s copy (PDF)
- Arlington PDF Model – the PDF Association’s machine-readable model of every PDF object, with the version each key was added in