Chapter.10 How to Use the Command-line

10–1 Execution Method

Antenna House PDF API Command-line application is executed by specifying arguments using the following configuration.

[Command-line application name] [command] [parameter] -d (input file/folder path) -o (output file/folder path)
The meaning of items:
  • [Command-line application name]:
    Application name of Antenna House PDF API.
    • Example: AHPDFToolCmd80.exe
  • [Command]:
    This is a command that specifies the processing of "Antenna House PDF API". Primarily processes PDFs in combination with parameters. With some exceptions (*1), the command setting is required. For details, see the explanation of associated command in "13 Parameters for Commands" in this manual.
    (*1) The command can be omitted only if -linearize is specified after the output file setting.
    • Example: -changeDocInfo
  • [Parameter]:
    This item is processed in pairs with commands. Some commands may have parameters that must be specified, while others may not require parameters. For details, see the explanation of associated command in "13 Parameters for Commands" in this manual.
    • Example: -title Val
  • -d (input file/folder path):
    Specifies the input file or input folder/directory. The input file may be other than PDF. Some commands do not require an input file. For details on how to specify, see "11-1 How to Specify Input and Output" in this manual.
    • Example: -d C:\test\test.pdf
  • -o (output file/folder path):
    Specifies the output file or output folder/directory. The output file may be other than PDF. Some commands do not require specifying an output file. For details on how to specify, see "11-1 How to Specify Input and Output" in this manual.
    • Example: -o C:\sav\out.pdf

10–1–1 Running on Windows Versions

Run the Windows version of the Command-line application with arguments as follows:

AHPDFToolCmd80.exe [command] [parameter] -d (Input file/folder path) -o (output file/folder path)

Note:
* Be sure to specify [command]. If not specified, an error will occur (*2).
(*2) Only if -linearize is specified with -o, it will be output without an error even without a command. * For commands that require parameters, be sure to specify "parameter" after specifying "command". If "parameter " is not specified, an error will occur. * The success or failure of execution and error code can be obtained from the return value obtained using the environment variable "ERRORLEVEL". For details, see "14-3 Error Handling" in this manual. * If an error occurs in PdfTk, the internal library of "PDF Tool API", during execution, a message text indicating the error content will be output to standard output. For details including error contents, see "14-3 Error Handling" in this manual.

10–1–2 Running on Linux Versions

Run the Linux version of the Command-line application with arguments as follows:

AHPDFToolCmd80 [command] [parameter] -d (input file/directory path) -o (output file/directory path)

In Linux versions, a shell script "run.sh" is placed by the installer. "run.sh" is a shell script that can be executed by setting the location information of command line applications and license files in environment variables.

Unlike Windows versions, the installer does not set environment variables on Linux versions. Instead, "run.sh" with installation destination information is included. (More precisely, "run.sh" is generated during installation after filling in information such as the deployment folder.)

When using "Antenna House PDF API" through a shell script, specify the arguments and execute it as follows:

sh run.sh [command] [parameter] -d (input file/folder path) -o (output file/folder path)

Once you run the shell script, you can run "AHPDFToolCmd80" on the command line without setting environment variables until you close the terminal.

Note:
* Be sure to specify [command] when executing. If not specified, an error will occur (*3).
(*3) Only if -linearize is specified with -o, it will be output without an error even without a command.

  • For commands that require parameters, be sure to specify "parameter" after specifying "command". If "parameter" is not specified, an error will occur.
  • The success or failure of execution can be obtained from the return value obtained using the variable "$?". For details, see "14-3 Error Handling" in this manual.
  • If an error occurs in PdfTk, the internal library of "PDF Tool API", during execution, a message text indicating the error content will be output to standard output. For details including error contents, see "14-3 Error Handling" in this manual.
  • Environment variable settings made by the shell script "run.sh" are retained only until the terminal is closed. If you want to set environment variables that are automatically read at login, such as Windows system environment variables, try setting environment variables for the execution environment using [/.profile], [.bashrc], and [/.bash_profile].