1mod fonts;
6mod images;
7mod render;
8#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
9mod wasm_bindings;
10
11pub use fonts::FontRegistry;
12pub use images::ImageEmbedError;
13pub use lightweight_pdf_core::*;
14pub use lightweight_pdf_fonts::FontError;
15pub use lightweight_pdf_layout::{LayoutWarning, LayoutWarningKind};
16pub use render::{DocumentExt, RenderError};
17#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
18pub use wasm_bindings::{LightweightPdf, RenderResult};
19
20#[cfg(all(feature = "wasm-size-probe", not(feature = "default-fonts")))]
21compile_error!(
22 "wasm-size-probe needs a font source: enable `default-fonts` alongside it (see plan/00a-contracts-and-artifacts.md, point 2)"
23);
24
25#[cfg(feature = "wasm-size-probe")]
33#[no_mangle]
34pub extern "C" fn lightweight_pdf_wasm_size_probe() -> i32 {
35 let mut doc = Document::new(PageFormat::A4);
36 doc.add(Text::new("Hallo Rechnung").size(18.0).bold());
37 let cell = |s: &str| Text::new(s).size(10.0);
38 doc.add(Row::new().gap(8.0).child(cell("Menge")).child(cell("Preis")));
39 doc.add(Line::new());
40 match doc.render() {
41 Ok(bytes) => i32::try_from(bytes.len()).unwrap_or(i32::MAX),
47 Err(_) => -1,
48 }
49}