In this chapter…

…you will learn about the options available within StampPDF Batch.

StampPDF Batch Options

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.

The following is an example of command syntax for StampPDF Batch.

$stamppdf [options] stampfile.txt input1.pdf [input2.pdf...]

The table below shows command-line options for StampPDF Batch.

Options summary

Option Parameter Description
-u string Removes stamps labeled with UndoLabel
-j  Integer Number of digits for Bates numbering
-sameversion Use the same PDF version as the input PDF file
-arabicfixedlength Do not increase the length of Arabic text
-vars  string List of variables to be substituted in the Stamp File ( “name,value,name,value” )
-vardelimiter string Delimiter character for variables in the stamp file
-cmds CommandFile.txt Process multiple command and files. Compatible with -l, -p, -r, -n, and -h or -help
-watch  File_Path path to watched folder base directory
-watchin  File_Path path to input watched folder; optional
-watchout  File_Path path to output of watched folder; optional

-u <UndoLabel>— Remove old stamps with UndoLabel (can be used more than once with different label)

Removes stamps that were labeled with  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 <integer>— Number of characters in Bates numbers (default 6)

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.

-sameversion — Use the same PDF version as the input PDF file

If the option -sameversion is set and the original version of a PDF is 1.4 or later, the original version is used.  If the option -sameversion is set and the original version is earlier than 1.4, the stamped PDF will be version 1.4.  The only exceptions arise if either of the options  -comp or  -iso32000 are set, in which case the stamped PDF will be version 1.7.

-arabicfixedlength — Do not increase the length of Arabic text

The output Arabic text will have the same length as the input text.  This option is related to how the ICU library performs “Arabic shaping”, it inserts extra Unicode characters to improve the appearance of the text. If more room is necessary, then the application will try to consume spaces next to modified characters.

Command Line Variable Substitution

-vars <string>— List of variables to be substituted in the Stamp File ( “name,value,name,value” )

StampPDF Batch will be able to replace variables found within the stamp file, and thus substitute the text that it stamps based on parameters set on the command line. If the text of an item contained in the stamp file contains one or more pairs of percent signs, the text between each pair of percent signs is the name of a variable to be replaced.

The command line uses the “-vars” flag to assign a value to each stamp. StampPDF Batch replaces each variable name (including the percent signs) by its value. The first part is the variable name set in the stamp file and the information following after the comma is the value for that variable. For example, if you have Text Parameters set with %First_Name% and %Last_Name% in the stamp file, your command line would look similar to the example below:

stamppdf -p -o outfile.pdf -vars "First_Name,Jane,Last_Name,Doe" StampFile.txt InputFile.pdf

There are rules that govern text replacement:

1) Variable names can consist of some characters from the ASCII range 32-126, including upper and lower case letters, numbers, spaces (but not leading or trailing spaces), and underscores.

2) Values can contain any UTF-8 characters except null.

3) Two consecutive commas in a value field are treated not as separators, but as a single comma that is part of the value.

4) A %variable-name% in the stamp file Text parameter that is not part of the -vars option will be left unchanged, but be aware that the percept sign, when coupled with the character following it, could be construed as a stamp variable, leading to unexpected results.

5) When you specify -vars on the command line, each stamp must have an even number of percent signs. If you want to mix new text replacement variables and traditional stamp variables in the same stamp file, you will need to add an additional percent sign in front of the StampPDF Batch built-in variable. The Text Parameters in your stamp file would look similar to the example below:

Text (Page %%g) ---- this is a StampPDF Batch built-in variable for Page number.
Add an extra % in front of the %g variable
Text (My Full Name is %First_Name% %Last_Name%)

If you omit the -vars flag from the command line, %%g in the Text parameter above will be stamped as %g on the output PDF file.

6) You can also add StampPDF Batch built-in variables to the command line.  Please note, you need to add double quotes around the built-in variables on Windows and single quotes on Unix.  Example of Text Parameter in the stamp file:

Text (Today is %My_Date%)
Windows: stamppdfapp.exe -p -o BuiltInVariable.pdf -vars "My_Date,%c" StampFile.txt InputFile.pdf
Unix: stamppdfapp -p -o BuiltInVariable.pdf -vars 'My_Date,%c' StampFile.txt InputFile.pdf

NOTE:  Text substitution on the command line must be composed of letters, numbers, underscores, and spaces, with no leading or trailing space.

NOTE:  If you are using built-in variables and command line variables in the same stamp file, you need to use a different character other than the percent sign % to represent the command line variable in the stamp item. For example, stamp item should appear as:

Text (#First_Name# #Last_Name# %B %d %Y)

stamppdfapp -p -o out.pdf -vars “First_Name,Jane,Last_Name,Smith” -vardelimiter # StampFIle.txt Input.pdf

Microsoft attaches special meaning to a bunchOfCharsbunchOfChars%. So, there may be cases where the user tries to use percent signs in the values in -vars, but Microsoft intervenes.

Another place where Microsoft uses percent signs is in the syntax of its DOS for command. There could be some mis-interpretation.

Command Collections

-cmds — Command Collections allow you to process a collection of files at one time

To process multiple commands quickly and efficiently, use the -cmds  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

Watched Folders

-watch — path to watched folder base directory

Activates the watch directory and executes the specified processing options when a document is dropped into the directory. All of the options can be used with the -watch option except the following: -h, -help, and -v.

To create a watch directory:

Make a new directory on the server
Open an instance of the server.
Change your working directory to the StampPDF Batch 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:
$stamppdf [options] -watch
The command activates the watch directory and runs continuously in the background, processing whatever options are specified. It also creates four subdirectories; error, in, original, and out, which are used during document processing

Example: Create a subdirectory called StampedFiles in the StampPDF Batch samples directory. Then enter the following command to activate it as a watch directory for stamping files.
In Windows:
>stamppdf.bat -p .\samples\stampitems1.txt -watch .\samples\StampedFiles\
$stamppdf -p ./samples/stampitems1.txt -watch ./samples/StampedFiles/

Following activation of the watch directory:

Give users access to the server so that they can use the watch directory
If you want to create multiple watch directories, repeat the steps using a new directory name and new server instance for each watch directory.
Processing documents with watch directories

To process documents using a watch directory:

Open the file management application in your GUI (graphical user interface).
Access the server where the watch directory is located.
Place the documents to be processed in the watch directory’s “in” subdirectory.
Retrieve the processed files from the watch directory’s “out” subdirectory.
Example: If a watch directory named StampedFiles has been set up, drag, copy, or FTP your PDF documents to its “in” subdirectory.

When the documents have been processed, the original files are moved to a subdirectory called “original” and the processed files are placed in a subdirectory called “out”. If there are any problems with the input files, they will be moved to the “error” subdirectory.

-watchin — path to input watched folder; optional

Path to input watched folder. Optional.

-watchout — path to output of watched folder; optional

Path to output watched folder. Optional.