loading arguments

Load command-line arguments from a YAML file

Details

You can use --args <file> anywhere in your command line to load arguments from a YAML file. This is recommended for complex workflows, escaping issues, or bypassing your operating system’s command-line length limits.

YAML Format

The file must be a flat YAML list of strings.

- in.pdf
- cat
- 1-3
- output
- out.pdf

Nested lists are flattened. This may be useful for organizing your files:

- # Input files
  - a.pdf
  - b.pdf
- cat

Pipeline Separators

If you use --- to separate YAML documents, it acts exactly like the pipeline separator (---) on the command line.

- in.pdf
- rotate
- right
---
- stamp
- logo.pdf
- output
- out.pdf

Escaping and Windows Paths

One consequence of using YAML is that unquoted strings treat backslashes and spaces as literal characters. This makes Windows paths safe without escaping.

- C:\Users\Name\My Document.pdf

If your filename contains a space followed by a hash (e.g., File #1.pdf), YAML will treat the hash as the start of a comment. To fix this, wrap the line in single quotes:

- 'C:\Users\Name\File #1.pdf'

Comments

You can use # to add comments to your argument files to document your workflow.

# Apply the final watermark
- stamp
- watermark.pdf

Examples

Load arguments from a YAML file

pdftl --args my_pipeline.yml

Mix direct arguments and loaded arguments

pdftl in.pdf --args operations.yml output out.pdf

Source: pdftl.cli.args_loader

Read online: https://pdftl.readthedocs.io/en/stable/general/args.html

Type: HelpTopic