Inside a PDF: Header, Objects, Streams, Cross-Reference Table and Trailer
A PDF looks like a printed page, but inside it is a structured file of numbered objects with an index at the end. The format is standardised as ISO 32000-1, and Adobe publishes the full text as PDF 32000-1:2008. Knowing the structure helps CS and IT students learn how a real binary-plus-text format is designed. It also explains everyday puzzles: why editing a PDF can make it bigger, why "compress PDF" works so well on scans, and why some PDFs cannot be copied as text.
In short: the specification says a basic PDF has four parts: a one-line header, a body of objects, a cross-reference table giving each object's byte position, and a trailer that points to the cross-reference table and the document's root object. Pages, fonts and images are all objects, and big data such as images lives in compressed streams.
The four parts of a PDF file
| Part | What it contains | What it looks like |
|---|---|---|
| Header | The PDF version the file conforms to | %PDF-1.7 |
| Body | The objects that make up the document: pages, fonts, images, content streams | 4 0 obj … endobj |
| Cross-reference table | Byte offset of every indirect object, for random access | xref followed by 20-byte entries |
| Trailer | Where the xref is, and which object is the document catalog (root) | trailer << /Root 1 0 R … >> startxref … %%EOF |
A reader opens a PDF from the end. It finds startxref, jumps to the cross-reference table, then loads only the objects it needs. That is how a 500-page PDF can open quickly on page 1.
The eight object types
The specification lists eight basic types of objects: Boolean values, integer and real numbers, strings, names, arrays, dictionaries, streams, and the null object.
| Type | Example |
|---|---|
| Boolean | true |
| Number | 612, 0.5 |
| String | (Admit card) or hex <4869> |
| Name | /Page, /FlateDecode |
| Array | [0 0 595 842] (an A4 page box in points, rounded) |
| Dictionary | << /Type /Page /Parent 2 0 R >> |
| Stream | A dictionary followed by stream … endstream bytes |
| Null | null |
An indirect object is numbered, for example 4 0 obj … endobj (object 4, generation 0). Other objects refer to it as 4 0 R. A PDF is therefore a graph: the trailer points to the Catalog, the Catalog to the page tree, each Page to its content stream, fonts and images.
A minimal page, annotated
%PDF-1.7
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 595 842]
/Contents 4 0 R /Resources << /XObject << /Im1 5 0 R >> >> >> endobj
4 0 obj << /Length 30 >> stream
q 595 0 0 842 0 0 cm /Im1 Do Q
endstream endobj
5 0 obj << /Type /XObject /Subtype /Image /Width 2480 /Height 3508
/ColorSpace /DeviceRGB /BitsPerComponent 8 /Filter /DCTDecode … >>
stream … JPEG bytes … endstream endobj
xref … trailer << /Root 1 0 R … >> startxref … %%EOF
This is, in simplified form, what a scanned page is: one page whose content stream draws one full-page image (/Im1 Do). The values shown (2480 × 3508 pixels, an A4 page at 300 DPI) are example values. Byte counts and offsets are left out for readability.
Streams and filters: where the size goes
Stream data is usually compressed, and the /Filter entry names the method. Common standard filters include:
- FlateDecode – zlib/DEFLATE, the same lossless method PNG uses. It is typical for text content streams and fonts. See PNG and DEFLATE.
- DCTDecode – the specification describes it as decompressing "data encoded using a DCT (discrete cosine transform) technique based on the JPEG standard". It is effectively a JPEG embedded in the PDF. See how JPEG compression works.
- CCITTFaxDecode and JBIG2Decode – compact methods for 1-bit black-and-white images, ideal for text scans.
A text PDF exported from Word is mostly small FlateDecode streams and fonts. A scanned PDF is mostly image streams, so its size is set by the pixel count and the JPEG quality of each page. PDF compressors work by re-encoding those images at a lower resolution or quality. How PDF compression works shows the numbers.
Incremental updates: why edited PDFs grow
The specification allows a PDF to be "updated incrementally without rewriting the entire file". Changes are appended: new or changed objects, a new cross-reference section listing only those objects, and a new trailer. Deleted objects are left in the file and only marked as deleted in the cross-reference section. So if you add a signature to a PDF several times, or fill and re-save a form, the old versions can still be inside the file and the size keeps growing. Rewriting the file, which compressors and "save as" do, drops the dead objects.
This also has a privacy side: content you "removed" may still be recoverable from an incrementally saved PDF. Rewrite the file before sharing sensitive documents.
Why you sometimes cannot copy text
- Scanned PDFs contain only an image, so there are no characters to copy. You need OCR.
- Legacy-font Hindi PDFs (for example Kruti Dev) contain Latin character codes drawn with a Hindi-looking font, so copying gives garbled English letters. See the Kruti Dev to Unicode guide.
Exercise
- Make a one-page PDF with the image to PDF tool. Open it in a plain text editor: you will see
%PDF-at the top,obj/endobjpairs, and%%EOFat the end. Some tools pack many small objects into a compressed "object stream", so not every object will be readable. - Search for
/Filterto see which compression is used for the image. - Compress the same PDF with the PDF compressor and compare the image object's /Width and /Height before and after.
See the effect of re-encoding page images on file size.
Open the PDF compressorFrequently asked questions
Why does a PDF get bigger after editing?
PDF supports incremental updates: changes are appended with a new cross-reference section, and old objects stay in the file. Re-saving or compressing rewrites the file without them.
What is a scanned PDF technically?
A page whose content stream draws a full-page image object, often stored with the DCTDecode (JPEG) filter. There are no text characters unless OCR adds them.
How does a PDF reader find page 1 quickly?
It reads startxref at the end of the file, jumps to the cross-reference table, and loads only the objects it needs.
Sources
Sources checked on 23 November 2026. Official notices and orders change; the latest version on the issuing body's website is final.