fop-cli-0.1.0 is not a library.
FOP CLI - Apache FOP Command-Line Interface
A high-performance command-line tool for converting XSL-FO documents to PDF format.
Features
- Fast conversion - Rust-based implementation for optimal performance
- Progress reporting - Real-time progress bars for large documents
- Statistics - Detailed processing metrics and timing information
- Validation - Validate XSL-FO documents without generating output
- Flexible options - Support for custom fonts, images, and PDF metadata
- Multiple output formats - JSON or text-based statistics
Installation
From Source
From Workspace
Usage
Basic Conversion
With Progress and Statistics
Validation Only
Verbose Output
Custom Resources
PDF Metadata
Advanced Options
Command-Line Options
Input/Output
<INPUT>- Input XSL-FO file (required)[OUTPUT]- Output PDF file (optional with--validate-only)
Processing Options
-v, --verbose- Enable verbose logging--stats- Show detailed statistics after conversion--validate-only- Only validate the XSL-FO document-q, --quiet- Suppress progress bars and animations--no-progress- Disable progress reporting (for scripting)
Resources
--images-dir <DIR>- Directory containing images--font-dir <DIR>- Directory containing fonts
PDF Options
--compress- Enable PDF compression (reduces file size)--pdf-version <VERSION>- PDF version (1.4, 1.5, 1.6, 1.7, 2.0) [default: 1.4]--author <AUTHOR>- Set PDF author metadata--title <TITLE>- Set PDF title metadata--subject <SUBJECT>- Set PDF subject metadata--keywords <KEYWORDS>- Set PDF keywords metadata
Performance
-j, --jobs <N>- Number of threads to use (default: auto-detect)--max-memory <MB>- Maximum memory usage in MB
Validation
--strict- Enable strict XSL-FO validation--fail-fast- Stop processing after first error
Output Format
--output-format <FORMAT>- Output format for validation results (text, json) [default: text]
Examples
Basic Document Conversion
# Simple conversion
# With progress and stats
Large Document Processing
# Show progress for large documents
# Use multiple threads
Validation Workflow
# Validate before generating
# If valid, generate PDF
Scripting Integration
# Disable progress bars for scripts
# Exit code indicates success (0) or failure (non-zero)
if ; then
else
fi
Production Deployment
# Compressed PDF with metadata
Output
Progress Output
Apache FOP
Rust Implementation
✓ Read input file: document.fo (5ms)
✓ Parsed FO tree (1243 nodes) (245ms)
✓ Layout complete (3456 areas) (1.2s)
✓ PDF rendered (42 pages) (890ms)
✓ Saved to document.pdf (15ms)
✓ Success!
Input: document.fo
Output: document.pdf
Size: 234.5 KB → 1.2 MB
Pages: 42
Time: 2.35s
Statistics Output (Text)
Processing Statistics:
⚙️ Parsing: 245ms
⚙️ Layout: 1.20s
⚙️ Rendering: 890ms
✨Total: 2.35s
•FO Nodes: 1243
•Areas: 3456
📄Pages: 42
Input size: 234.5 KB
Output size: 1.2 MB
Size ratio: 5.12x
Throughput: 17.87 pages/sec
Statistics Output (JSON)
Performance Tips
For Large Documents
- Use multiple threads:
-j 8(adjust based on CPU cores) - Enable compression:
--compress(reduces output size) - Suppress progress:
--quiet(slight performance gain)
For Batch Processing
#!/bin/bash
for; do
pdf_file=".pdf"
done
For CI/CD Pipelines
# Example GitHub Actions workflow
- name: Generate PDF
run: |
fop document.fo document.pdf \
--quiet \
--fail-fast \
--stats \
--output-format json > stats.json
Error Handling
The CLI returns different exit codes:
0- Success1- Error (parsing, layout, rendering, or I/O)
Errors are printed to stderr with detailed context:
Error: Failed to parse XSL-FO document
Caused by:
0: Unexpected element: fo:invalid-element
1: Line 42, column 5
Logging
Set RUST_LOG environment variable for fine-grained control:
# Debug all FOP modules
RUST_LOG=debug
# Only show errors
RUST_LOG=error
# Module-specific logging
RUST_LOG=fop_core=debug,fop_layout=info
Building
# Debug build
# Release build (optimized)
# Run tests
# Run clippy
License
Apache License 2.0
See Also
- FOP Core - FO tree parsing
- FOP Layout - Layout engine
- FOP Render - PDF rendering