Section:

Command-line PDF editing functions

Apryse's PDF PageMaster is an efficient solution designed for splitting, merging, editing, and securing PDF documents, while presenting several options to control output document settings. This section includes the command string syntax, used both in the PDF PageMaster Command-Line Application as well as in PDF PageMaster SDK.

Basic Syntax

The basic command-line syntax is:

pagemaster [options] file1 file2 folder1 file3 ...

See more options in Command-Line Summary for PDF PageMaster

General Usage Examples

This section covers the basic usage of PDF PageMaster, explaining all the available options and illustrating examples.

Batch Processing and the Use of Wildcards

PDF PageMaster supports processing of multiple input documents in the same run. For example, it is possible to specify multiple PDF folders and PDF PageMaster will automatically process all PDF documents matching a given file extension. For example, the following command-line will process all PDF documents in folders 'test1' and 'test2'

c:\>pagemaster -o c:/output_folder c:/test1 c:/test2

Wildcard characters can also be used to process multiple input files.

For example, if a directory contains the following PDF documents:

sh

1C:\test1 >dir
2 Directory of C:\test1
3 01/04/2007 03:35 PM <DIR> .
4 01/04/2007 03:35 PM <DIR> ..
5 05/21/2004 02:27 PM A1.pdf
6 05/03/2005 09:38 AM A2.pdf
7 05/20/2003 08:46 AM B1.pdf
8 05/15/2003 12:50 PM B2.pdf

To merge all PDF documents in this folder, you could specify:

pagemaster -m -o c:/output_file.pdf c:/test1/*.pdf

To merge all PDF documents staring with 'A', you could specify:

pagemaster -o c:/output_file.pdf c:/test1/A*.pdf

Or, to process all PDF documents ending with '1', you could specify:

pagemaster -o c:/output_file.pdf c:/test1/*1.pdf

You can use either of the two standard wildcards --- the question mark (?) and the asterisk (*) --- to specify filename and path arguments on the command-line.

The wildcards are expanded in the same manner as operating system commands. (Please refer to your operating system user's guide if you are unfamiliar with wildcards). Enclosing an argument in double quotation marks (" ") suppresses the wildcard expansion. Within quoted arguments, you can represent quotation marks literally by preceding the double-quotation-mark character with a backslash (\). If no matches are found for the wildcard argument, the argument is passed literally.\

Exit Codes

To provide additional feedback, PDF PageMaster returns exit codes after completing processing. The exit codes can be used to provide user feedback, for logging etc. This is particularly important for applications running in an unattended environment.

The following table lists possible exit codes and their description:

sh

1Exit Code Description
2--------------- ------------------------------------------------------------------
30 No errors. All files converted successfully.
41 Unspecified error.
52 Bad license key.
63 Failed to create the output directory.
74 Bad input filename or path.
85 Output file not specified.
96 Error reading the input document.
107 Document is secured. Need a valid password to open the document.
118 Error writing an output file or folder
129 No input files found

All codes other then '0' indicate that there was an error during the conversion process.

The following illustrates a sample Windows batch script that processes exit codes:

sh

1@echo off rem run a simple merge operation...
2pagemaster -o OUT -m in1.pdf in2.pdf In1Folder
3if errorlevel 9 goto inputerr
4if errorlevel 7 goto passwd
5if errorlevel 1 goto othererror
6if errorlevel 0 goto exit
7
8:passwd
9echo **Document is protected. Need a valid password to open the document**.
10goto exit
11
12:inputerr
13echo No input files specified.
14goto exit
15
16:othererror
17echo An error encountered during processing.
18goto exit
19
20:exit

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales