hipdf
A high-level PDF manipulation library built on lopdf, focusing on ease of use and powerful abstractions for common PDF operations following the ISO 32000-2 standard.
Features
- Optional Content Groups (OCG): Easy creation and management of PDF layers
- Layer Management: High-level API for organizing content into toggleable layers
- Hatching Patterns: Support for various fill patterns including crosshatching, dots, and custom patterns
- PDF Embedding: Embed other PDF documents with various layout strategies
- Type Safety: Strongly typed interfaces with compile-time guarantees
Quick Start
Creating PDF Layers
use ;
use ;
// Create a new PDF with layers
let mut doc = with_version;
let mut ocg_manager = with_config;
// Add layers
ocg_manager.add_layer;
ocg_manager.add_layer;
ocg_manager.add_layer;
// Initialize layers in document
ocg_manager.initialize;
// Build content for specific layers
let mut builder = new;
builder.begin_layer
.add_operation
.add_operation
.end_layer;
Adding Hatching Patterns
use ;
// Create a hatching manager
let mut manager = new;
// Add a diagonal pattern
let pattern_id = manager.add_pattern;
// Create a shape with the pattern
let mut builder = new;
builder.rectangle;
Embedding PDFs
use ;
// Create an embedder
let mut embedder = new;
// Load a PDF
embedder.load_pdf?;
let options = EmbedOptions ;
// Embed into target document
embedder.embed_pdf?;
Modules
- [
ocg] - Optional Content Groups (layers) functionality - [
hatching] - Hatching and pattern support for PDF documents - [
embed_pdf] - PDF embedding and composition support
Usage Examples
Layer Management
use ;
// Create layer manager
let mut manager = new;
// Add layers with different visibility settings
manager.add_layer;
manager.add_layer;
manager.add_layer;
// Initialize in PDF document
manager.initialize;
Custom Hatching Patterns
use ;
// Create custom pattern
let mut pattern_builder = new;
pattern_builder
.move_to
.line_to
.line_to;
// Register the pattern
let custom_pattern_id = manager.add_custom_pattern;
Advanced PDF Embedding
use ;
// Create layout builder
let mut layout_builder = new;
// Add multiple PDFs with different layouts
layout_builder
.add_pdf
.add_pdf;
// Generate the final document
let final_doc = layout_builder.build?;
Requirements
- Rust 1.70+
- lopdf 0.38.0
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
API Documentation
For complete API documentation, visit docs.rs/hipdf.