pdf-converter

Crates.iopdf-converter
lib.rspdf-converter
version0.1.0
created_at2025-06-22 01:31:23.625934+00
updated_at2025-06-22 01:31:23.625934+00
descriptionA simple and efficient library for converting images (JPG, PNG, GIF, BMP, WebP) to PDF documents. Commercial use permitted under MIT/Apache-2.0 license.
homepagehttps://github.com/topki/pdf-converter
repositoryhttps://github.com/topki/pdf-converter
max_upload_size
id1721221
size95,148
(topki0325)

documentation

https://docs.rs/pdf-converter

README

PDF Converter

License: MIT License: Apache 2.0 Commercial Use

A simple and efficient Rust library for converting images to PDF documents with support for multiple formats and commercial use.

โœจ Features

  • ๐Ÿ–ผ๏ธ Multi-format Support: JPG, PNG, GIF, BMP, WebP
  • ๐Ÿ“„ Single & Batch Conversion: Convert individual files or entire folders
  • ๐Ÿ“ Smart A4 Fitting: Automatic scaling with proper margins
  • โš™๏ธ Configurable: Custom DPI, margins, page size, document title
  • ๐Ÿš€ Performance Optimized: Memory-efficient processing
  • ๐Ÿ’ผ Commercial Friendly: MIT/Apache-2.0 dual license
  • ๐Ÿ› ๏ธ Production Ready: Comprehensive error handling and testing

๐Ÿš€ Quick Start

Add to your Cargo.toml:

[dependencies]
pdf-converter = "0.1.0"

Basic Usage

use pdf_converter::PdfConverter;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let converter = PdfConverter::new();
    
    // Convert a single image
    converter.convert_image_to_pdf("image.jpg", "output.pdf")?;
    
    // Convert entire folder to single PDF
    converter.convert_folder_to_pdf("images/", "batch_output.pdf")?;
    
    Ok(())
}

Advanced Configuration

use pdf_converter::{PdfConverter, PdfConfig};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let config = PdfConfig {
        dpi: 300.0,
        margin_mm: 20.0,
        title: Some("My Document".to_string()),
    };
    
    let converter = PdfConverter::with_config(config);
    converter.convert_folder_to_pdf("images/", "high_quality.pdf")?;
    
    Ok(())
}

๐Ÿ“Š Performance

  • Single image: ~1 second
  • Batch (4 images): ~6 seconds
  • Memory: Optimized for large files
  • Quality: 100-300 DPI support

๐Ÿงช Testing

Run the comprehensive test suite:

cargo run --bin comprehensive_test

Or quick validation:

cargo run --bin quick_test

๐Ÿ“ Project Structure

src/
โ”œโ”€โ”€ lib.rs          # Public API
โ”œโ”€โ”€ converter.rs    # Core conversion logic
โ””โ”€โ”€ error.rs        # Error handling
examples/
โ”œโ”€โ”€ basic_usage.rs  # Simple example
โ””โ”€โ”€ batch_convert.rs # Batch processing

๐Ÿ’ผ Commercial Use

This project is 100% commercial-friendly:

  • โœ… Use in proprietary software
  • โœ… Sell products containing this code
  • โœ… No copyleft restrictions
  • โœ… Modify and redistribute
  • โœ… Patent protection (Apache-2.0)

Perfect for:

  • Commercial applications
  • SaaS products
  • Enterprise software
  • Consulting projects
  • Proprietary systems

๐Ÿ“„ License

Dual licensed under your choice of:

  • MIT License - Simple and permissive
  • Apache License 2.0 - Includes patent protection

See LICENSE-MIT and LICENSE-APACHE for details.

๐Ÿ‘ค Author

topki
๐Ÿ“ง Email: 259901434@qq.com

๐Ÿค Contributing

Contributions are welcome! This project is designed for easy contribution with:

  • Clear module separation
  • Comprehensive error handling
  • Extensive test coverage
  • Good documentation

๐Ÿ”— Links


Made with โค๏ธ by topki โ€ข Commercial use permitted โ€ข Production ready

Commit count: 0

cargo fmt