Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

CLI Reference

The printwell command-line tool provides access to all printwell features.

Global Options

printwell [OPTIONS] <COMMAND>

Options:
  -v, --verbose    Increase verbosity (-v, -vv, -vvv)
  -q, --quiet      Suppress output
  -h, --help       Print help
  -V, --version    Print version

Commands

convert

Convert HTML to PDF.

printwell convert [OPTIONS] <INPUT>

Arguments:

  • <INPUT> - HTML file path, URL, or - for stdin

Options:

OptionDescriptionDefault
-o, --output <FILE>Output PDF file path-
--page-size <SIZE>Page size: A3, A4, A5, Letter, Legal, TabloidA4
--width <LENGTH>Custom page width (e.g., “210mm”)-
--height <LENGTH>Custom page height (e.g., “297mm”)-
--margin <MARGINS>Page margins (e.g., “10mm” or “10mm,20mm,10mm,20mm”)10mm
--landscapeUse landscape orientationfalse
--no-backgroundDon’t print background graphicsfalse
--scale <FACTOR>Scale factor1.0
--page-ranges <RANGES>Pages to print (e.g., “1-5,8”)All
--header <HTML>Header HTML template-
--footer <HTML>Footer HTML template-
--timeout <DURATION>Resource fetch timeout30s
--font <SPEC>Custom font (format: “family:path”)-

Metadata Options:

OptionDescription
--title <TEXT>PDF document title
--author <TEXT>PDF document author
--subject <TEXT>PDF document subject
--keywords <TEXT>PDF document keywords (comma-separated)
--creator <TEXT>PDF creator application name
--producer <TEXT>PDF producer name

Form Detection Options:

OptionDescription
--detect-formsDetect HTML form elements and output their positions
--convert-formsAuto-convert detected HTML forms to native PDF form fields
--forms-output <FILE>Output detected form elements to JSON file
--validate-forms <FILE>Validate detected forms against rules JSON file
--validation-output <FILE>Output validation results to JSON file

Boundary Extraction Options:

OptionDescription
--boundaries <SELECTORS>CSS selectors for boundary extraction (comma-separated)
--boundaries-output <FILE>Output boundaries to JSON file

Examples:

# Basic conversion
printwell convert report.html -o report.pdf

# From URL with custom page size
printwell convert https://example.com -o example.pdf --page-size Letter

# Landscape with custom margins
printwell convert input.html -o output.pdf --landscape --margin "25mm,10mm,25mm,10mm"

# With header and footer
printwell convert input.html -o output.pdf \
    --header '<div style="font-size:9px">Header</div>' \
    --footer '<div style="font-size:9px">Page <span class="pageNumber"></span></div>'

# With custom fonts and metadata
printwell convert input.html -o output.pdf \
    --font "MyFont:./fonts/custom.ttf" \
    --title "My Document" \
    --author "John Doe"

# From stdin
cat template.html | printwell convert - -o output.pdf

convert-batch

Convert multiple HTML files to PDF in batch.

printwell convert-batch [OPTIONS] <INPUTS>...

Options:

OptionDescriptionDefault
-o, --output-dir <DIR>Output directory for generated PDFs.
--workers <NUM>Maximum concurrent conversions4
--page-size <SIZE>Page sizeA4
--backgroundPrint background colors and imagesfalse
--landscapeUse landscape orientationfalse

Examples:

# Convert multiple files
printwell convert-batch file1.html file2.html file3.html -o ./output

# With 8 parallel workers
printwell convert-batch *.html -o ./pdfs --workers 8

watermark

Add watermark to PDF. Requires the watermark feature.

printwell watermark [OPTIONS] <INPUT> -o <OUTPUT>

Options:

OptionDescriptionDefault
-o, --output <FILE>Output PDF file pathRequired
--text <TEXT>Watermark text-
--image <FILE>Watermark image path (PNG or JPEG)-
--position <POS>Position: center, top-left, top-center, top-right, middle-left, middle-right, bottom-left, bottom-center, bottom-right, or “x,y”center
--rotation <DEG>Rotation in degrees (counter-clockwise)0
--opacity <FLOAT>Opacity (0.0-1.0)0.3
--font-size <PT>Font size in points72
--color <COLOR>Color as hex (e.g., “#FF0000”) or name (e.g., “gray”)gray
--foregroundPlace watermark in foregroundfalse
--pages <SELECTION>Pages: “1,3,5”, “1-10”, “odd”, “even”, “first”, “last”all
--scale <FACTOR>Scale factor for the watermark1.0

Examples:

# Text watermark
printwell watermark document.pdf -o watermarked.pdf --text "DRAFT"

# Diagonal confidential watermark
printwell watermark document.pdf -o watermarked.pdf \
    --text "CONFIDENTIAL" \
    --rotation 45 \
    --opacity 0.2 \
    --color "#FF0000"

# Image watermark
printwell watermark document.pdf -o watermarked.pdf \
    --image logo.png \
    --position bottom-right \
    --opacity 0.5

# Watermark only odd pages
printwell watermark document.pdf -o watermarked.pdf \
    --text "SAMPLE" \
    --pages odd

bookmarks

Add or extract bookmarks from a PDF. Requires the bookmarks feature.

printwell bookmarks [OPTIONS] <INPUT>

Options:

OptionDescription
-o, --output <FILE>Output PDF file (for adding bookmarks)
--add <SPEC>Add bookmark (format: “title:page” or “title:page:y_position” or “title:page:y_position:parent_index”)
--extract <FILE>Extract bookmarks to JSON file
--from-json <FILE>Add bookmarks from JSON file
--format <FMT>Output format for extraction: text, json

Examples:

# Add bookmarks inline
printwell bookmarks document.pdf -o output.pdf \
    --add "Chapter 1:1" \
    --add "Chapter 2:5" \
    --add "Chapter 3:10"

# Add bookmarks from JSON
printwell bookmarks document.pdf -o output.pdf --from-json bookmarks.json

# Extract bookmarks to JSON
printwell bookmarks document.pdf --extract bookmarks.json

# Extract bookmarks as text
printwell bookmarks document.pdf --extract - --format text

annotate

Add, list, or remove annotations from a PDF. Requires the annotations feature.

printwell annotate [OPTIONS] <INPUT>

Options:

OptionDescription
-o, --output <FILE>Output PDF file
--highlight <SPEC>Add highlight (format: “page:x:y:width:height” or “page:x:y:width:height:color”)
--note <SPEC>Add sticky note (format: “page:x:y:contents”)
--underline <SPEC>Add underline (format: “page:x:y:width:height”)
--strikeout <SPEC>Add strikeout (format: “page:x:y:width:height”)
--square <SPEC>Add rectangle (format: “page:x:y:width:height:color”)
--listList existing annotations
--removeRemove all annotations (or specific types)
--page <NUM>Page to filter for remove operation (1-indexed)
--color <HEX>Default annotation color
--format <FMT>Output format for list: text, json

Examples:

# Add highlight
printwell annotate document.pdf -o annotated.pdf \
    --highlight "1:100:200:150:20"

# Add sticky note
printwell annotate document.pdf -o annotated.pdf \
    --note "1:50:100:Review this section"

# List annotations
printwell annotate document.pdf --list --format json

# Remove all annotations
printwell annotate document.pdf -o cleaned.pdf --remove

encrypt

Encrypt PDF with password protection. Requires the encrypt feature. Commercial license required.

printwell encrypt [OPTIONS] <INPUT> -o <OUTPUT>

Password Options:

OptionDescription
--owner-password <PASS>Owner password (visible in process listings)
--owner-password-file <FILE>Read owner password from file (more secure)
--owner-password-env <VAR>Read owner password from environment variable
--user-password <PASS>User password (visible in process listings)
--user-password-file <FILE>Read user password from file (more secure)
--user-password-env <VAR>Read user password from environment variable

Permission Options:

OptionDescription
--allow-printAllow printing
--allow-print-hqAllow high-quality printing
--allow-copyAllow copying text and graphics
--allow-accessibilityAllow extracting text for accessibility
--allow-modifyAllow modifying the document
--allow-annotateAllow adding annotations
--allow-assembleAllow assembling the document
--allow-fill-formsAllow filling form fields
--allow-allAllow all permissions

Other Options:

OptionDescriptionDefault
--algorithm <ALG>aes256, aes128, or rc4aes256

Examples:

# Basic encryption with owner password from file
printwell encrypt document.pdf -o encrypted.pdf --owner-password-file secret.txt

# With user password and restrictions
printwell encrypt document.pdf -o encrypted.pdf \
    --owner-password-env OWNER_PASS \
    --user-password-env USER_PASS \
    --allow-print --allow-fill-forms

decrypt

Decrypt a password-protected PDF. Requires the encrypt feature. Commercial license required.

printwell decrypt [OPTIONS] <INPUT> -o <OUTPUT>

Options:

OptionDescription
--password <PASS>Password (visible in process listings)
--password-file <FILE>Read password from file (more secure)
--password-env <VAR>Read password from environment variable

sign

Digitally sign a PDF. Requires the signing feature. Commercial license required.

printwell sign [OPTIONS] <INPUT> -o <OUTPUT>

Options:

OptionDescriptionDefault
--certificate <FILE>PKCS#12 certificate file (.p12/.pfx)Required
--password <PASS>Certificate password (visible in process listings)-
--password-file <FILE>Read password from file (more secure)-
--password-env <VAR>Read password from environment variable-
--reason <TEXT>Reason for signing-
--location <TEXT>Location of signing-
--level <LEVEL>PAdES level: B, T, LT, LTAB
--timestamp-url <URL>Timestamp server URL-
--visible <FIELD>Visible signature field name-
--position <SPEC>Visible signature position (format: “page:x,y,w,h”)-
--certifyCreate a certification signaturefalse
--mdp <LEVEL>MDP permissions: 1=no-changes, 2=form-filling, 3=annotations2

Examples:

# Invisible signature
printwell sign document.pdf -o signed.pdf \
    --certificate certificate.p12 \
    --password-file pass.txt \
    --reason "Approved" \
    --location "New York"

# Visible signature with timestamp
printwell sign document.pdf -o signed.pdf \
    --certificate certificate.p12 \
    --password-env CERT_PASS \
    --visible "Signature1" \
    --position "1:400,50,150,50" \
    --timestamp-url "http://timestamp.digicert.com"

# Certification signature
printwell sign document.pdf -o certified.pdf \
    --certificate certificate.p12 \
    --password-file pass.txt \
    --certify \
    --mdp 2

verify

Verify PDF signatures. Requires the signing feature. Commercial license required.

printwell verify [OPTIONS] <INPUT>

Options:

OptionDescriptionDefault
--format <FMT>Output format: text, jsontext
--use-system-trustUse system trust store for certificate chain validationfalse

list-fields

List signature fields in a PDF. Requires the signing feature. Commercial license required.

printwell list-fields [OPTIONS] <INPUT>

Options:

OptionDescriptionDefault
--format <FMT>Output format: text, jsontext

forms

Add form fields to PDF. Requires the forms feature. Commercial license required.

printwell forms [OPTIONS] <INPUT> -o <OUTPUT>

Options:

OptionDescription
--text-field <SPEC>Add text field (format: “name:page:x,y,w,h”)
--checkbox <SPEC>Add checkbox (format: “name:page:x,y,size”)
--dropdown <SPEC>Add dropdown (format: “name:page:x,y,w,h:opt1,opt2,…”)
--signature-field <SPEC>Add signature field (format: “name:page:x,y,w,h”)

Examples:

# Add form fields
printwell forms document.pdf -o form.pdf \
    --text-field "name:1:50,700,200,20" \
    --text-field "email:1:50,650,200,20" \
    --checkbox "agree:1:50,600,15" \
    --signature-field "signature:1:50,500,200,50"

pdfa-validate

Validate PDF/A compliance. Requires the pdfa feature. Commercial license required.

printwell pdfa-validate [OPTIONS] <INPUT>

Options:

OptionDescriptionDefault
--level <LEVEL>PDF/A level: 1b, 1a, 2b, 2u, 2a, 3b, 3u, 3a2b
--format <FMT>Output format: text, jsontext

pdfa-convert

Add PDF/A metadata to a PDF. Requires the pdfa feature. Commercial license required.

printwell pdfa-convert [OPTIONS] <INPUT> -o <OUTPUT>

Options:

OptionDescriptionDefault
--level <LEVEL>PDF/A level: 1b, 1a, 2b, 2u, 2a, 3b, 3u, 3a2b
--title <TEXT>Document title-
--author <TEXT>Document author-

pdfua-validate

Validate PDF/UA accessibility compliance. Requires the pdfua feature. Commercial license required.

printwell pdfua-validate [OPTIONS] <INPUT>

Options:

OptionDescriptionDefault
--level <LEVEL>PDF/UA level: 1, 21
--format <FMT>Output format: text, jsontext

pdfua-convert

Add PDF/UA accessibility metadata to a PDF. Requires the pdfua feature. Commercial license required.

printwell pdfua-convert [OPTIONS] <INPUT> -o <OUTPUT>

Options:

OptionDescriptionDefault
--level <LEVEL>PDF/UA level: 1, 21
--title <TEXT>Document title-
--language <LANG>Document language (BCP 47 format, e.g., “en-US”)en

info

Display PDF/renderer information.

printwell info [OPTIONS] [INPUT]

Arguments:

  • [INPUT] - Optional PDF file to inspect

Options:

OptionDescription
--rendererShow renderer information

Examples:

# Show renderer info
printwell info --renderer

# Inspect PDF file
printwell info document.pdf

Output:

printwell 0.1.0
Chromium: 120.0.6099.0
Skia: m120
Build: release

Exit Codes

CodeDescription
0Success
1General error
2Invalid arguments
3Input file not found
4Output write error
5Conversion error
6Validation failed