Expand description
§html2pdf-secure
A Rust crate for converting HTML to password-protected PDF files.
This crate provides functionality to:
- Convert HTML content to PDF using headless Chrome
- Add password protection to generated PDFs
- Support various PDF encryption options
§Quick Start
use html2pdf_secure::{Html2PdfConverter, PdfOptions, PasswordOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let converter = Html2PdfConverter::new().await?;
let html = "<html><body><h1>Hello, World!</h1></body></html>";
let password_opts = PasswordOptions::new("user123", "owner456");
let pdf_data = converter
.convert_html_to_protected_pdf(html, PdfOptions::default(), password_opts)
.await?;
std::fs::write("output.pdf", pdf_data)?;
Ok(())
}
Re-exports§
pub use converter::Html2PdfConverter;
pub use encryption::PasswordOptions;
pub use encryption::EncryptionLevel;
pub use encryption::PdfPermissions;
pub use error::Html2PdfError;
pub use error::Result;
pub use options::PdfOptions;
pub use options::PageFormat;
pub use options::PageOrientation;
pub use options::PageMargins;
Modules§
- converter
- HTML to PDF conversion functionality using headless Chrome.
- encryption
- PDF encryption and password protection functionality.
- error
- Error types for the html2pdf-secure crate.
- options
- Configuration options for PDF generation.