Crate json2pdf_client

Source
Expand description

json2pdf Client library

This library is a client library for the json2pdf server. json2pdf is a Java webserver that generates PDF documents from a JSON model.

§Example

Generate a PDF documentation with some text and an image

use json2pdf_client::*;

async fn generate_pdf() {
    let spec = DocumentSpecification::new()
        .add_element(Element::paragraph(Paragraph::new("Hello world!"))
            .border(BorderSettings::new()
                .bottom(BorderSpecification::new(4f32))))
        .add_element(Element::image(Image::new_bytes(&Vec::new(), 400f32, 400f32)));

    let data = pdf("http://localhost:8080", &spec).await.unwrap();
}

Structs§

BorderSettings
Settings for the border of an element. If a side is left unset, no border will be created for that side
BorderSpecification
Settings for a specific border
Column
A column in a row
DocumentSpecification
The specification for the PDF document
Element
Image
An image
Paragraph
A paragraph
Row
A row in a table
Table
A table

Functions§

pdf
Generate a PDF document accordign to the provided specification