PDF preserves the design and formatting of a document. However, its pages are difficult to edit. This becomes a problem when you want to add new information to a PDF page.
For example, if you have a web server and want to add a timestamp or user information to a PDF as it is served to the user. Or if you have a web-based document management system that requires downloaded PDFs to be watermarked "DRAFT". Or maybe when visitors download sample documents you want to add invisible text to the front page to help you track that document. Then this guide is for you!
Will these instructions also work for manipulating local PDFs? Yes. STAMPtk and PDFtk are both available for Windows and Mac OS X as well as Linux. They are both command-line tools, so they are better suited for use by power-users and developers.
Introducing PDFtk Server
PDFtk Server is free (as in freedom) software that you can use to manipulate PDF documents. You can download free installers for Windows and Mac OS X from our site. Most Linux distributions maintain a "pdftk" binary package you can install.
Using PDFtk, you can overlay one PDF’s pages on top of another PDF so they look superimposed. This operation is called
multistamp. The stamp PDF can have one or more pages. If it has multiple pages, then each stamp page is applied to each page of the target PDF in order. If the target PDF has more pages than the stamp PDF, then the final stamp page is repeated over the remaining target PDF pages.
For example, to apply
in.pdf and create a new PDF, the pdftk command would be:
pdftk in.pdf multistamp stamp.pdf output out.pdf
stamp.pdf is a single page, then it will be applied to every page in
in.pdf to create
stamp.pdf has five pages and
in.pdf has ten pages, then the first five pages of
stamp.pdf will be applied in order to the first five pages of
in.pdf. Then page five of
stamp.pdf will be applied to the remaining pages (6-10) of
So, you already have
in.pdf. How can you make the perfect
stamp.pdf? Read on, friend.
STAMPtk is a fast tool for creating basic PDF pages and documents. It is perfect for making the
stamp.pdf PDF in the example, above. It is commercial software that comes with support and a 30-day satisfaction guarantee. We don’t offer a trial version, but if it doesn’t do the job then we’ll refund your purchase.
Its manual explains all of its features in detail. Let’s look at some examples to get an idea of what is possible.
Make a Stamp with STAMPtk
First let’s make a big DRAFT stamp. We’ll make it translucent using the
stamptk alpha=0.4 AAtext="DRAFT" AApos=center,center AAsize=100 AAangle=NE AAfont=sansBold output=stamp.pdf
stamp.pdf looks like this:
Now let’s apply this stamp to a document:
pdftk in.pdf multistamp stamp.pdf output out.pdf
out.pdf looks like this (note how the text under the stamp is visible due to our use of the STAMPtk
The STAMPtk options we used to create this stamp are pretty self-explanatory. To add another piece of text to
stamp.pdf, add new options but use a different prefix. For example:
stamptk alpha=0.4 AAtext="DRAFT" AApos=center,center AAsize=100 AAangle=NE AAfont=sansBold BBtext="Latest" BBsize=50 BBcolor=255,0,0 BBorigin=left,top BBpos=left,top output=stamp.pdf
Yields a PDF with both black and red (translucent) text:
I should note that the
alpha option is applied to all text in STAMPtk’s output PDF.
If the STAMPtk command line starts getting too long, consider using its
include option that can take page options (one per line) from a file or stdin.
Change Page Size and Text Position
What else can you do with STAMPtk?
STAMPtk’s default page size is Letter (8.5" x 11"). If you want an A4-sized page, use the
media option like this:
AAmedia=A4. To make the media landscape, append
You can position text on the page using relative coordinates (
bottom) or using absolute coordinates. You’ll probably want to set the text’s origin, which is used to position the text. For example, the default text origin in
center,center, which is handy for centering text on the page like we did in the first example. In the second example, we used the text origin of
left,top for "Latest" because we wanted it to fit nicely in the
left,top position of the page.
In our next example, we will use these relative coordinates to make a document header and footer.
Make Headers and Footers with STAMPtk
Next let’s make a multi-page stamp with custom headers and footers. This
stamp.pdf is 15 pages long, and even-numbered pages have a different header than the odd-numbered pages:
stamptk AAmedia=A4 AAtext="Specially Prepared for John Hancock" AAorigin=left,top AApos=left,top AArange=1-15Odd BBmedia=A4 BBtext="Prepared July 4, 1776" BBorigin=right,top BBpos=right,top BBrange=1-15Even CCmedia=A4 CCtext="Final Version" CCorigin=center,bottom CCpos=center,bottom CCrange=1-15 output=stamp.pdf
Since STAMPtk knows the media size, it can accurately position the text using relative terms. You can control how close to the edge it goes by setting the
margin option (e.g.
Note that we set the media size for each piece of text. This is a good practice for pieces of text that share the same page. (You can include pages of different sizes in one STAMPtk call.)
Subject to the terms of its license, one STAMPtk Server License allows you to install and run STAMPtk on ONE production server and THREE development computers. It includes support, but does not allow distribution. It also comes with a 30-day satisfaction guarantee. If it doesn’t fit your needs, we will refund your purchase.
The price for one license is $95. STAMPtk is available for 64-bit Linux, 32-bit Linux, Windows, Mac OS X and other platforms.