This directory contains practical examples demonstrating all parsing methods.
# Run any example
node test/examples/01-basic-parse.js
node test/examples/06-smart-parser.js
node test/examples/07-compare-all.jsBasic PDF parsing with default options.
- Learn: How to parse a PDF with minimal code
- Best for: Quick integration, simple use cases
Batch processing with different batch sizes.
- Learn: How to optimize batch size for your PDFs
- Best for: Small to medium PDFs (< 1000 pages)
Streaming parse with progress tracking.
- Learn: Memory-efficient parsing with visual progress
- Best for: Large PDFs with limited memory
Worker threads for true multi-core parallelism.
- Learn: How to use all CPU cores for huge PDFs
- Best for: PDFs with 1000+ pages on multi-core systems
Child processes for maximum performance.
- Learn: Multi-processing for fastest parsing
- Best for: Huge PDFs (often faster than workers)
SmartPDFParser with automatic method selection.
- Learn: How the smart parser chooses the best method
- See: Fast-path optimization, caching, statistics
- Best for: Production use, mixed PDF sizes
Compare all methods on the same PDF.
- Learn: Performance differences between methods
- See: Benchmark results, speedup factors
- Best for: Understanding when to use which method
All examples work with the included test PDFs:
node test/examples/01-basic-parse.js
node test/examples/02-batch-parse.js
node test/examples/06-smart-parser.jsSome examples perform better with large PDFs:
# Place a large PDF in test/data/test_9000.pdf
node test/examples/04-workers-parse.js
node test/examples/05-processes-parse.js
node test/examples/07-compare-all.jsIf large PDF is not found, examples automatically use smaller test files.
- When to use batch vs workers vs processes
- How oversaturation improves CPU utilization
- Impact of batch size on performance
- Fast-path optimization (50x faster overhead)
- Decision caching (25x faster on cache hit)
- CPU-aware thresholds (adapts to your hardware)
- Error handling
- Progress tracking
- Method comparison
- Statistics monitoring
- Start with SmartPDFParser (example 06) - it auto-selects the best method
- Run comparison (example 07) to see differences on your hardware
- Test batch sizes (example 02) to find optimal configuration
- Monitor progress (examples 03, 04, 05) for long-running tasks
After trying examples:
- Read the main README.md for full documentation
- Check lib/README.md for architecture details
- See benchmark/ for benchmarking tools
All examples are production-ready code! Copy and adapt them for your projects.