In this chapter…

…you will learn how to run StampPDF Batch on the command line.

  • Running StampPDF Batch shows how to run StampPDF Batch software with various configurations of command-line options.
  • Running StampPDF Batch with PHP provides documentation on the free PHP class for StampPDF Batch
  • Examples runs through the lettersample example, and lists the other samples included with StampPDF Batch.

Running StampPDF Batch

The minimum recommended form of the StampPDF Batch command is:

$stamppdf -o output1.pdf stampfile.txt input1.pdf

This stamps the file input1.pdf with the stamps described in stampfile.txt, and saves the resulting file with the new stamps as output1.pdf. The original input1.pdf remains unstamped.

Use the -l and -p options to create a log file or print to the screen feedback about the operation of StampPDF Batch:

$stamppdf -o output1.pdf -l logfile.txt -p stampfile.txt input1.pdf

Note: Order is important. In the example above, we have the following elements:

  1. The stamppdf command
  2. Options
  3. The stamp file
  4. The input file

The -o and -l options must be followed by filenames or you won’t get the results you expect.

Stamp several documents with one stamp file

StampPDF Batch can stamp several PDF documents with the same stamp file at one time, but can only use one stamp file at a time. There are a couple of ways to do this:

  • List multiple files on the command line
  • Use wildcards

Note: If you use the -o option, specify the name of an existing directory. If you specify a filename, all but the first of your original files will be overwritten.

Listing multiple files

The following command stamps both Sample1.pdf and Sample2.pdf at the same time as defined by StampItems1.txt:

$stamppdf StampItems1.txt Sample1.pdf Sample2.pdf

Using wildcards

Instead of listing all the files on the command line, use ? or * to match one or more characters in a filename:

file?.pdf stamps any file named file + any single character + .pdf

$./stamppdf StampItems1.txt Sample?.pdf

*.pdf stamps any file in the current working directory with the .pdf extension:

$./stamppdf StampItems1.txt *.pdf

Sample* stamps any PDF file in the current working directory that starts with “Sample” in the filename:

$./stamppdf StampItems1.txt Sample*

* stamps any PDF file in the current working directory:

$./stamppdf StampItems1.txt *

Note: StampPDF Batch will fail if it tries to stamp a file that is not a PDF document. We recommend always using .pdf in file specifications (the first two examples). If you leave out the .pdf extension, make sure the working directory contains only PDF files.

Running StampPDF Batch with PHP

StampPDF Batch can easily be run from user-written php code using the AppligentStampPDF Class. The class is a “wrapper” function, packaged to allow the PHP developer to easily run StampPDF Batch from any PHP script.


In this section we examine some of the samples in the StampPDF Batch Samples subdirectory. Stamp Files describes the stamp file LetterStamp.txt in detail.

Stamping company information on a business letter

Find lettersample.pdf in the Samples subdirectory. This example uses the stamp file letterstamp.txt to stamp lettersample.pdf.

The sample document lettersample.pdf is a single page business letter. With letterstamp.txt, StampPDF Batch applies the following stamps:

  • A header with the Appligent, Inc. company logo
  • A PDF file containing the Appligent return address
  • The current date
  • A watermark of “Confidential” across the page
  • An image of a signature
  • A disclaimer in a multi-line footer

Note: In the following examples, we use relative path names for clarity. We recommend using full path names at all times.

To stamp the lettersample.pdf file:

Change your working directory to the StampPDF Batch directory. The stamp file letterstamp.txt uses relative paths from here for the image files. It will fail if you do not run from this directory.

The default location for StampPDF Batch on Windows is:


On other platforms, it will be wherever you installed it.

Enter the following command (UNIX and Mac OS X):

$./stamppdf -o ./samples/letterout.pdf ./samples/letterstamp.txt ./samples/lettersample.pdf

or in Windows:

>stamppdf -o .\samples\letterout.pdf .\samples\letterstamp.txt .\samples\lettersample.pdf

Open ./Samples/letterout.pdf and ./Samples/lettersample.pdf in Acrobat or Acrobat Reader and compare them to see the stamps applied.

Close both files when you are finished.

Removing a stamp

Use the -u <UndoLabel> command to remove a stamp from a document. In letterstamp.txt, the Signature stamp has an UndoLabel called undoStamp.

To remove the Signature stamp:

Make sure you are still in the StampPDF Batch working directory.

Enter the following command (UNIX and Mac OS X):

$./stamppdf -u undoStamp ./samples/letterout.pdf

or in Windows

>stamppdf -u undoStamp .\samples\letterout.pdf

Open ./samples/letterout.pdf in Acrobat or Acrobat Reader and verify that the signature image has been removed.

Close the file when you are finished.

Running the other samples

StampPDF Batch includes these other samples:

  • sample1.pdf and stampitems1.txt
  • sample2.pdf and stampitems2.txt
  • CJK_stamp.utx, which stamps Japanese characters using UTF-8 and UTF-16, if you have support for Unicode installed. Use this stamp file with any PDF file.

These samples demonstrate many features available in StampPDF Batch. Run them to see what StampPDF Batch can do.