A PDF is a container of numbered objects, a table that says where each one starts, and a trailer that says where to begin reading. Pages are objects, fonts are objects, and the drawing instructions for each page are a stream of operators. Work with files using the Rotate PDF, PDF Metadata Editor and PDF to Text Converter; the term is defined in PDF (Portable Document Format).
The four parts of a file
- Header:
%PDF-1.4names the version. - Body: numbered objects such as
3 0 obj ... endobj(object number, generation, then the content). - Cross-reference table (
xref): for each object, the byte offset where it starts, so a reader can jump straight to it. - Trailer: names the root object (
/Root) and ends withstartxref, the offset of the table, then%%EOF.
A complete minimal PDF
This one-page file is complete. Its offsets are real: pdfinfo reads it as one 200 × 100 point page and pdftotext extracts "Hello PDF".
%PDF-1.4
1 0 obj
<< /Type /Catalog /Pages 2 0 R >>
endobj
2 0 obj
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
endobj
3 0 obj
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 200 100] /Contents 4 0 R /Resources << /Font << /F1 5 0 R >> >> >>
endobj
4 0 obj
<< /Length 39 >>
stream
BT /F1 18 Tf 20 50 Td (Hello PDF) Tj ET
endstream
endobj
5 0 obj
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
endobj
xref
0 6
0000000000 65535 f
0000000009 00000 n
0000000058 00000 n
0000000115 00000 n
0000000241 00000 n
0000000330 00000 n
trailer
<< /Size 6 /Root 1 0 R >>
startxref
400
%%EOF
How the pieces fit
- The
/Rootcatalog points to the page tree (/Pages), which lists the pages (/Kids). - Each page has a
/MediaBox(size in points; 72 points = 1 inch) and/Contents, a stream such asBT ... ETthat sets a font, moves to a position and shows text. - Resources like fonts are referenced by name (
/F1) and defined elsewhere. - Real files compress streams (
/Filter /FlateDecode) and store many objects together in object streams to save space. - Metadata lives in the
/Infodictionary and optionally in XMP; see and change it with the PDF Metadata Editor.
Why it matters
- Edits can be saved as an incremental update: new objects and a new
xrefare appended, and the old ones stay in the file. Deleted or redacted content may remain recoverable. - Text extraction depends on how a font maps glyphs to characters; scanned pages hold only images and need OCR.
- A corrupt
xrefcan often be rebuilt by scanning forobjmarkers, which is how many readers repair damaged files. - To check a document for hidden changes, see How to Check a PDF for Hidden Changes.