Graphics Programs Reference
In-Depth Information
How a PDF File is Written
Writing a PDF document to a series of bytes in a file is much simpler than reading it—
we don't need to support all of the PDF format, just the subset we intend to use. Writing
a PDF file is very fast, since it amounts to little more than flattening the object graph
to a series of bytes.
1. Output the header.
2. Remove any objects which are not referenced by any other object in the PDF. This
avoids writing objects which are no longer needed.
3. Renumber the objects so they run from 1 to n where n is the number of objects in
the file.
4. Output the objects one by one, starting with object number one, recording the byte
offset of each for the cross-reference table.
5. Write the cross-reference table.
6. Write the trailer, trailer dictionary, and end-of-file marker.
Search WWH ::




Custom Search