Chapter 2. Building a Simple PDF

In this chapter, we’ll build PDF content manually in a text editor. Then we’ll use the free pdftk program to turn it into a valid PDF file and look at the output in a PDF viewer.

This example, together with all the PDF files in this book, can be downloaded from the web page for this book.

We’ll be looking at a lot of new concepts all at once, so don’t worry if it seems overwhelming—we’ll come back to all of this in future chapters.

Basic PDF Syntax

A PDF file contains at least three distinct languages:

  • The document content, which is a number of objects with links between them forming a directed graph. These objects describe the structure of the document (pages, metadata, fonts, and resources).

  • The page content, described using a series of operators for placing text and graphics on a single page.

  • The file structure, consisting ...

Get PDF Explained now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.