basic/
basic.rs

1use std::collections::HashMap;
2use zpl_forge::forge::png::PngBackend;
3use zpl_forge::{Resolution, Unit, ZplEngine};
4
5fn main() {
6    let zpl_input = r#"
7        ^XA
8        ^FO50,50^A0N,50,50^FDZPL Forge^FS
9        ^FO50,120^GB300,100,2^FS
10        ^FO70,140^A0N,30,30^FDHello World!^FS
11        ^FO50,250^BCN,100,Y,N,N^FD12345678^FS
12        ^XZ
13    "#;
14
15    let engine = ZplEngine::new(
16        zpl_input,
17        Unit::Inches(4.0),
18        Unit::Inches(3.0),
19        Resolution::Dpi203,
20    )
21    .expect("Error parsing ZPL");
22
23    let png_backend = PngBackend::new();
24    let png_bytes = engine
25        .render(png_backend, &HashMap::new())
26        .expect("Error rendering");
27
28    std::fs::write("example_output.png", png_bytes).expect("Error writing file");
29    println!("Label successfully generated in 'example_output.png'");
30}