The pages are stored in a page structure, a balanced tree. The top node contains an integer with the number of pages. The maximal integer number in PDF and TeX is 231−1 (2,147,483,647). However indirect objects are needed to store
pages in the PDF format (PDF specification):
- 1 Page node per page;
- 1 Resources object per page (pdfTeX generates the object for each page, even
if the resource objects are the same and could be shared);
- 1 Contents object per page (in theory equal pages could share the same object, but it is not supported by pdfTeX and unlikely for real documents).
- Overhead of the page tree structure with additional kid nodes;
- And the document has a few additional objects (e.g. Catalog, Info).
Thus more than 3 indirect objects are needed per page. But the number of indirect objects (indirect objects are PDF objects that can be referenced by the object number and are recorded in the cross reference section) is limited:
The following test file explores the maximal number of pages with pdfTeX.
It does only generates minimal pages without fonts, annotations.
The pages are completely empty (
% pdftex --ini test.tex
Tested with pdfTeX 3.1415925-2.4-1.40.13 (TeX Live 2012).
File size: 862,082,448 bytes
PDF without object stream compression
If the page number is increased by one, then pdfTeX complains with an error message:
! TeX capacity exceeded, sorry [indirect objects table size=8388607].
PDF object stream compression of PDF-1.5 decreases the file size, but
costs indirect objects for storing the object streams. That decreases the maximal number of pages. For testing, replace
\iftrue in the example above and play with the setting for
File size: 329,412,496
PDF with object stream compression
In practice especially annotations costs objects (and therefore pages), whereas fonts can be reused throughout the document.
The theoretical maximal number of pages for PDF files with pdfTeX is 2,621,437 (empty pages and without object stream compression of PDF-1.5).