@zohocorporation/zpdf-cli
v1.0.1
Published
A powerful cross-platform CLI for PDF manipulation - compress, merge, split, protect, watermark, and more
Maintainers
Readme
@zohocorporation/zpdf-cli
A powerful cross-platform CLI for PDF manipulation built with Kotlin Multiplatform.
Installation
npm install -g @zohocorporation/zpdf-cliOr install locally in your project:
npm install @zohocorporation/zpdf-cliFeatures
- Compress - Reduce PDF file size with configurable compression levels
- Merge - Combine multiple PDFs into one
- Split - Split a PDF into separate pages or ranges
- Protect - Add password protection to PDFs
- Unprotect - Remove password protection from PDFs
- Flatten - Flatten annotations and form fields
- Rotate - Rotate pages in a PDF
- Extract - Extract specific pages from a PDF
- Info - Display PDF metadata and information
- Linearize - Optimize PDFs for web viewing (fast web view)
- Watermark - Add text or image watermarks
- Insert Blank - Insert blank pages
- Insert Pages - Insert pages from another PDF
- Delete Pages - Remove pages from a PDF
- Swap Pages - Reorder pages in a PDF
- Replace Page - Replace a page with content from another PDF
- Copy - Create a copy of a PDF
- Extract Attachments - Extract embedded files from a PDF
- Overlay - Overlay one PDF on top of another
Usage
Basic Commands
# Show help and available commands
zpdf-cli --help
# Show help for a specific command
zpdf-cli compress --helpCompress PDF
# Basic compression with default settings
zpdf-cli compress -i input.pdf -o output.pdf
# Maximum compression for smallest file size
zpdf-cli compress -i input.pdf -o output.pdf -l maximum
# Available compression levels: none, low, medium (default), high, maximumMerge PDFs
# Merge multiple PDFs
zpdf-cli merge -i file1.pdf -i file2.pdf -i file3.pdf -o merged.pdfSplit PDF
# Split into individual pages
zpdf-cli split -i input.pdf -o output_dir/
# Split specific page range
zpdf-cli split -i input.pdf -o output.pdf --start 1 --end 5Protect PDF
# Add password protection
zpdf-cli protect -i input.pdf -o protected.pdf -p "userpassword"
# Add both user and owner passwords
zpdf-cli protect -i input.pdf -o protected.pdf -p "userpass" --owner-password "ownerpass"Unprotect PDF
# Remove password protection (requires password)
zpdf-cli unprotect -i protected.pdf -o unprotected.pdf -p "password"Rotate Pages
# Rotate all pages 90 degrees clockwise
zpdf-cli rotate -i input.pdf -o output.pdf -a 90
# Rotate specific pages
zpdf-cli rotate -i input.pdf -o output.pdf -a 90 --pages 1,3,5Watermark
# Add text watermark
zpdf-cli watermark -i input.pdf -o output.pdf -t "CONFIDENTIAL"
# Add watermark with custom options
zpdf-cli watermark -i input.pdf -o output.pdf -t "DRAFT" --opacity 0.3 --font-size 48Extract Pages
# Extract specific pages
zpdf-cli extract -i input.pdf -o output.pdf --pages 1,3,5-10Get PDF Info
# Display PDF information
zpdf-cli info -i input.pdfFlatten PDF
# Flatten annotations and form fields
zpdf-cli flatten -i input.pdf -o output.pdfLinearize (Fast Web View)
# Optimize for web viewing
zpdf-cli linearize -i input.pdf -o output.pdfPlatform Support
| Platform | Architecture | Status | |----------|--------------|--------| | macOS | arm64 (Apple Silicon) | ✅ | | macOS | x64 (Intel) | ✅ | | Linux | x64 | ✅ | | Windows | x64 | ✅ |
Output Format
All commands return JSON output for easy integration with scripts and other tools:
{
"success": true,
"message": "PDF compressed successfully",
"data": {
"originalSize": 10485760,
"compressedSize": 5242880,
"compressionRatio": "50.0%"
}
}Exit Codes
0- Success1- Error (check stderr for details)
License
MIT License - see LICENSE file for details.
