The Portable Document Format is another graphical document format published by Adobe. PDF is not a general-purpose programming language as the PostScript (see PostScript export). Instead, it a binary data format intended for interactive viewing. To improve performance for interactive viewing, PDF defines a more structured format than that used by most PostScript language programs. PDF also includes objects, such as annotations and hypertext links, that are not part of the page itself but are useful for interactive viewing and document interchange. See http://vrr.ucw.cz/doc/PDFReference16.pdf for complete reference.
The PDF file is organized into streams, where each stream contains some part of the document. There are cross-references among these streams. The PDF export is a little bit more complicated when compared to PostScript export (see PostScript export). The table of contents is located at the end of the file and there is a lot of indirect references, which means that the exporter has to keep track of the positions of all exported streams.
Not counting the complications caused by references, the PDF export is also straightforward. After writing the PDF header, the fonts are exported, together with the corresponding font headers. TrueTypes are fully supported, the Type1 fonts are required to be stored in the PFB format and in a special way, which is done by FONTLIB, see FONTLIB. Then the exporter walks through the GO list and exports the objects one by one by outputting the corresponding commands and arguments, preceded by graphical environment (colors, line widths, etc.) setup and surrounded by graphical stack save and restore commands. At the end, the PDF content table is stored.
The source is in the file export/pdf.c, consult it for details.