html_to_pdf_lib

Crates.iohtml_to_pdf_lib
lib.rshtml_to_pdf_lib
version0.1.2
sourcesrc
created_at2024-07-23 09:26:09.475936
updated_at2024-07-23 12:00:58.545735
descriptionA library for converting HTML to PDF.
homepage
repository
max_upload_size
id1312595
size38,963
Bansikah (Bansikah)

documentation

README

Convert HTML to pdf library Rust

This repository contains the htmltopdf Rust library, which converts HTML to PDF. Below are instructions for integrating and using this library in different environments.

Prerequisites

  • Rust installed on your system
  • Java Development Kit (JDK) installed
  • Maven installed

Building the Rust Library

  1. Clone the Repository

    Clone the repository containing the html_to_pdf_lib Rust library.

    git clone https://github.com/Bansikah/htmltopdflib
    cd htmltopdflib
    
Build the Rust Library

Build the Rust library to generate the shared library file (.so, .dll, or .dylib) for JNI.

```sh
cargo build --release
cargo run file.html

The shared library will be located in the target/release directory. The filename will be html_to_pdf_lib..

Usage Rust project

To use html_to_pdf_lib in your Rust project, follow these steps:

  1. Add the library as a dependency in your Cargo.toml:

    [dependencies]
    html_to_pdf_lib = "0.1.0"
    
  2. Use the library in your Rust code:

    use html_to_pdf_lib::convert_html_to_pdf;
    
    fn main() -> Result<(), Box<dyn std::error::Error>> {
        let html_content = r#"
            <!DOCTYPE html>
            <html>
            <head>
                <title>Sample PDF</title>
            </head>
            <body>
                <h1>Hello, World!</h1>
                <p>This is a sample PDF generated from HTML.</p>
            </body>
            </html>
        "#;
    
        let output_path = "output.pdf";
        convert_html_to_pdf(html_content, output_path)?;
    
        println!("PDF generated successfully at {}", output_path);
    
        Ok(())
    }
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

Commit count: 0

cargo fmt