StampPDF Batch Usage
In this chapter...
...you will learn how to run StampPDF Batch on the command line.
- Using Command-Line Options describes the command-line options available when running StampPDF Batch.
- 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.
Using Command-Line Options
Command-line options are used in all Appligent server applications. The table below shows command-line options for StampPDF Batch. The following is an example of command syntax for StampPDF Batch.
$stamppdf [options] stampfile.txt input1.pdf [input2.pdf...]
Options summary
| Type | Option | Parameter | Description |
|---|---|---|---|
| General | -l | logFile | Write progress information to log file |
| -p | Provide progress messages | ||
| -r | RegNum | Pass registration number to StampPDF Batch | |
| -n | Do not write information to screen | ||
| -v | Display version information | ||
| -h or -help | Display usage information | ||
| -o | outFile.pdf | Save output to a new file or directory | |
| -w | Linearize the file upon save | ||
| -i | Perform incremental save | ||
| -d | oPassword | Owner password to open document, if necessary | |
| -optimize | Optimize the output file to try to reduce file size | ||
| -nocomp | Do not compress using Object Streams (resulting file is compatible with all versions of Acrobat) | ||
| -comp | Compress using Object Streams (resulting file requires Acrobat 6 and later) | ||
| -iso32000 | Set file for ISO 32000 compliance (PDF 1.7) | ||
| Specific | -u | UndoLabel | Removes stamps labeled with UndoLabel |
| -j | <n> | Number of digits for Bates numbering | |
| -cmds | CommandFile.txt | Process multiple command and files. Compatible with -l, -p, -r, -n, and -h or -help |
General options detailed
Refer to General Command-Line Options for details on the general options. Refer to Applying Standard Security for more information about the -d option and working with encrypted documents.
Note: There are four new options available in StampPDF Batch 5.0:
-optimize — Optimize the file (optional)
This flag will do the following: 1) encode any non-encoded streams using Flate compression, 2) remove ASCII85 filters from all streams, 3) replace LZW encoded streams with Flate encoding, 4) merge identical XObjects and images, 5) optimize common sequences in page content, and 6) merge identical font descriptors and encodings. This option will usually result in a smaller file size.
-nocomp — Do not compress using Object Streams (optional)
This flag will not compress Object Streams, resulting in a document that is compatible with all versions of Acrobat.
-comp — Compress using Object Streams (optional)
This flag will compress Object Streams, resulting in a document that is compatible with Acrobat 6.0 and later.
-iso32000 — Set file for ISO 32000-1 compliance (optional)
This flag sets the file for compliance with ISO 32000-1:2008 (PDF 1.7).
Specific options detailed
-u <UndoLabel>
Removes stamps that were labeled with <UndoLabel> in the stamp file. StampPDF Batch cannot remove stamps applied without an UndoLabel. You can use the -u option repeatedly on the same command line to remove stamps with different UndoLabels at the same time. You cannot stamp a document and remove stamps at the same time. Choose one action or the other. See UndoLabel (optional) for more information.
Note: Keep a record of UndoLabel parameter names. UndoLabel names are case-sensitive. You cannot remove a stamp unless you include the exact UndoLabel name in the command.
-j <n>
Specifies the number of digits when using Bates page numbering with the %J or %C variable. Page numbers are filled in with leading zeros to always have a specific number of digits. See Using variables in stamp files for more information.
The default value is 6.
-cmds — Allows you to process a collection of files at one time
To process multiple commands quickly and efficiently, use the -cmds <filename> option. The file specified by -cmds, the commands file, should contain one or more single line commands. Each command is just like an ordinary StampPDF Batch command-line without the executable name. The commands file does not support wildcards in filenames. The following is an example of command line syntax when running with -cmds:
$ ./stamppdf -p -l logfile.txt -cmds CommandFile.txt
CommandFile.txt contains a list of commands for StampPDF Batch to process. This is an example of the CommandFile.txt:
-p -iso32000 /appligent/stampbatch/samples/stampfile1.txt -o /appligent/stampbatch/samples/out_sample1.pdf /appligent/stampbatch/samples/sample1.pdf
-p -optimize /appligent/stampbatch/samples/stampfile2.txt -o /appligent/stampbatch/samples/out_sample2.pdf /appligent/stampbatch/samples/sample2.pdf
-p -w /appligent/stampbatch/samples/stampfile3.txt -o /appligent/stampbatch/samples/out_sample3.pdf /appligent/stampbatch/samples/sample3.pdf
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:
- The stamppdf command
- Options
- The stamp file
- 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.
Examples
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:
>C:\Appligent\StampPDFBatch\
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.