Skip to main content

Crate jubarte_render

Crate jubarte_render 

Source
Expand description

§jubarte-render

The render product of the jubarte engine: convert::docx_to_pdf and friends lay a Word document out page by page and write a PDF (or PNG pages) with Word-faithful layout - the fidelity benchmarks measure the word revision style against Microsoft Word’s own Save as PDF. The pure option types (PdfOptions, RevisionStyle, …) live in jubarte-opc’s render_options and are re-exported here at their historical convert:: paths.

§Example

use jubarte_render::convert::{PdfOptions, RevisionStyle, docx_to_pdf, docx_to_pdf_with, docx_to_png};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let docx = std::fs::read("redline.docx")?;

    // Default options: tracked changes in the conventional colours.
    std::fs::write("redline.pdf", docx_to_pdf(&docx)?)?;

    // Tracked changes drawn the way Microsoft Word prints them.
    let word = PdfOptions { revisions: RevisionStyle::Word, ..PdfOptions::default() };
    std::fs::write("redline-word.pdf", docx_to_pdf_with(&docx, word)?)?;

    // One PNG per page, at 96 dpi.
    for (n, png) in docx_to_png(&docx, PdfOptions::default(), 96.0)?.iter().enumerate() {
        std::fs::write(format!("page-{}.png", n + 1), png)?;
    }
    Ok(())
}

Modules§

admission
Input admission: budgets, refusal reasons, and the limits types the bindings and CLI expose. Resource admission for untrusted DOCX input: bound the ZIP container before anything inflates it without limits.
convert
DOCX to PDF and PNG, with Word-faithful layout. Independent DOCX → PDF, PNG and page-text conversion (no LibreOffice or Word process is involved).
namespaces
WordprocessingML and related namespace / XName constants. WordprocessingML and related namespace / XName constants ported from PtOpenXmlUtil.ts (the subset the comparer references) — M1.7.
opc
Open Packaging Conventions adapter (PartFs). OPC (Open Packaging Conventions) layer — M1.5.
util
Shared small utilities. Small shared utilities, ported from PtUtil.ts (M1.6).
xmllinq
Arena DOM (xmllinq) used by the comparer. LINQ-to-XML-style mutable XML tree, ported from lib/xml-linq.ts.