Expand description
§pdfcrop
A library and CLI tool for cropping PDF files with automatic bounding box detection.
This library provides functionality to:
- Detect bounding boxes of PDF content through content stream parsing
- Crop PDF pages with custom margins
- Support manual bounding box override
- Process PDFs page by page or in batch
§Library Usage Example
use pdfcrop::{crop_pdf, CropOptions, BoundingBox, Margins};
let pdf_data = std::fs::read("input.pdf")?;
let options = CropOptions {
margins: Margins::uniform(10.0),
bbox_override: None,
..Default::default()
};
let cropped = crop_pdf(&pdf_data, options)?;
std::fs::write("output.pdf", cropped)?;Re-exports§
pub use bbox::detect_bbox;pub use bbox::BoundingBox;pub use crop::crop_pdf;pub use error::Error;pub use error::Result;pub use margins::Margins;
Modules§
- bbox
- Bounding box detection and manipulation
- content_
filter - Content stream filtering to remove elements outside crop box
- crop
- Main PDF cropping logic
- error
- Error types for pdfcrop operations
- ghostscript
- Ghostscript integration for accurate bounding box detection
- margins
- Margin calculations and utilities
- pdf_ops
- PDF manipulation operations using lopdf
Structs§
- Crop
Options - Options for PDF cropping operations
Enums§
- BBox
Method - Bounding box detection method
- Page
Range - Page range specification for selective cropping