CLI Tools
Vanilla.PDF ships with vanillapdf-tools, a command-line utility for
common PDF operations.
Building the CLI tool
vanillapdf-tools is built automatically as part of the default build:
cmake --preset linux-x64-gcc # or any other preset
cmake --build --preset linux-x64-gcc
The binary is placed in the build output directory.
Available commands
Run vanillapdf-tools --help to see the full list of commands.
Command |
Description |
|---|---|
|
Digitally sign a PDF document using a PKCS#12 key |
|
Sign using custom signature callbacks |
|
Verify digital signatures in a PDF |
|
Combine multiple PDF documents into one |
|
Extract images from a PDF |
|
Extract a specific object by number |
|
Encode or decode content streams with compression filters |
|
Encrypt a PDF with password protection |
|
Remove encryption from a PDF |
|
Write a PDF with custom observer callbacks |
sign
Digitally sign a PDF document using a PKCS#12 key file:
vanillapdf-tools sign -s input.pdf -d signed.pdf -k private_key.p12 -p password
Option |
Description |
|---|---|
|
Source PDF file |
|
Destination (signed) PDF file |
|
PKCS#12 key file containing certificate and private key |
|
Password for the key file |
verify
Verify digital signatures in a PDF document:
vanillapdf-tools verify -f signed.pdf
Option |
Description |
|---|---|
|
Signed PDF file to verify |
|
Directory containing trusted certificates (optional, uses system defaults) |
|
Skip X.509 chain validation (testing only) |
|
Allow weak algorithms such as MD5 and SHA-1 |
|
Validate certificate at signing time instead of current time |
For details on verification status codes, see Signature Verification Guide.
merge
Combine multiple PDF documents into a single file:
vanillapdf-tools merge -s base.pdf -d merged.pdf -f extra1.pdf extra2.pdf
Option |
Description |
|---|---|
|
Base PDF file |
|
Destination (merged) PDF file |
|
One or more PDF files to merge into the base |
extract
Extract images from a PDF document:
vanillapdf-tools extract -s document.pdf
Extracted images are saved as separate files named
<object_number>.<generation_number>.
Option |
Description |
|---|---|
|
Source PDF file |
extract_object
Extract a specific object from a PDF by its object and generation numbers:
vanillapdf-tools extract_object -s document.pdf -o 5 -g 0
Option |
Description |
|---|---|
|
Source PDF file |
|
Object number |
|
Generation number |
filter
Encode or decode PDF content streams using various compression filters:
vanillapdf-tools filter -f flate encode -s input.bin -d compressed.bin
vanillapdf-tools filter -f flate decode -s compressed.bin -d output.bin
Option |
Description |
|---|---|
|
Filter type and operation: |
|
Source file |
|
Destination file |
Supported filter types: flate, dct, jpx, ascii85,
ascii_hex.
encrypt
Encrypt a PDF document with password protection:
vanillapdf-tools encrypt -s input.pdf -d encrypted.pdf -op owner123 -up user123
Option |
Description |
|---|---|
|
Source PDF file |
|
Destination (encrypted) PDF file |
|
Owner password |
|
User password |
|
Encryption algorithm: |
|
Key length in bits (default: 40) |
decrypt
Remove encryption from a PDF document:
vanillapdf-tools decrypt -s encrypted.pdf -d decrypted.pdf -p password
Option |
Description |
|---|---|
|
Encrypted PDF file |
|
Destination (decrypted) PDF file |
|
User or owner password |
|
Path to PKCS#12 file for certificate-based decryption (optional) |
write_custom
Write a PDF to a new file with custom observer callbacks:
vanillapdf-tools write_custom -s input.pdf -d output.pdf
Option |
Description |
|---|---|
|
Source PDF file |
|
Destination PDF file |
This command demonstrates the FileWriterObserverHandle callback interface.
See write_custom.c
for the implementation.