Graphics Programs Reference
In-Depth Information
Stamps and Watermarks
A stamp is a PDF page placed over another so that the page contents are combined. A
watermark (which pdftk calls a background ) is the same, but the stamp is placed under
the existing page contents. This doesn't work well if the pages of the input PDF have
a colored background, since the watermark often won't show through.
With pdftk , this is achieved using the stamp and watermark operations, which place the
stamp on (or under) all the pages in the given range. If the page sizes differ, the stamp
is scaled to fit and centered.
For example:
pdftk file.pdf stamp stamp.pdf output output.pdf
How a Stamp is Added
When a program like pdftk adds a stamp to an input PDF, the following steps must be
taken:
1. Load and parse both files into PDF object graphs.
2. Rectify the object numbers in both PDFs so that they are mutually exclusive. The
objects from the stamp PDF may now be added to the input PDF.
3. The page data for the stamp is appropriately scaled and centered with relation to
the page size of each page in the source PDF.
4. The page data for the stamp is appended to the page data for source PDF on each
page. Resources like fonts and images must all be renamed so as not to clash. Any
unmatched stack operators ( q / Q ) must be matched up prior to adding the new data.
5. The PDF can now be written to the output file.
Extracting and Setting Metadata
Pdftk can extract a document's metadata (author, title etc.) to a text file, either in ASCII
format (with non-ASCII characters encoded as XML-style numerical entities) or as
Unicode UTF8. This is achieved with the dump_data or dump_data_utf8 keywords. For
example:
pdftk input.pdf dump_data output data.txt
writes the data in Example 9-1 to data.txt .
Example 9-1. Example output of pdftk dump_data operation (ellipses indicate where we have
truncated the output for brevity)
InfoKey: Creator
InfoValue: XSL Formatter V4.3 R1 (4,3,2008,0424) for Linux
InfoKey: Title
InfoValue: PDF Explained
Search WWH ::




Custom Search