docs.rs failed to build zpl-rs-0.1.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
zpl-rs
A Rust library for rendering ZPL (Zebra Programming Language) labels to images.
This crate provides bindings to go-zpl, a native ZPL parser and renderer. Everything runs locally - no external services required.
Features
- Parse and render ZPL to PNG images
- Support for text, barcodes (Code 128, QR, DataMatrix, PDF417, etc.), and graphics
- Configurable DPI (203, 300, 600)
- Cross-platform: Linux, macOS, Windows (x64 and ARM64)
- Automatic library download at build time
Installation
Add to your Cargo.toml:
[]
= "0.1"
Quick Start
use render;
Advanced Usage
use ;
let zpl = "^XA^FO50,50^A0N,30,30^FDHello!^FS^XZ";
let options = new
.dpi
.size; // 4" x 6" at 300 DPI
let png_bytes = render_with_options.expect;
API
Functions
render(zpl: &str) -> Result<Vec<u8>>- Render ZPL with default settings (203 DPI)render_bytes(zpl: &[u8]) -> Result<Vec<u8>>- Render ZPL bytes (non-UTF8 safe)render_with_options(zpl: &str, options: &RenderOptions) -> Result<Vec<u8>>- Render with custom optionsrender_bytes_with_options(zpl: &[u8], options: &RenderOptions) -> Result<Vec<u8>>- Render bytes with options
Types
Dpi- Printer DPI:Dpi203,Dpi300,Dpi600RenderOptions- Configuration for rendering (DPI, width, height)Error- Error types:ParseError,RenderError,InternalError
Supported Platforms
| Platform | Architecture | Status |
|---|---|---|
| Linux | x86_64 | ✅ |
| Linux | aarch64 | ✅ |
| macOS | x86_64 | ✅ |
| macOS | aarch64 | ✅ |
| Windows | x86_64 | ✅ |
| Windows | aarch64 | ✅ |
Thread Safety
Important: The underlying Go library is not thread-safe for concurrent renders. If you need to render from multiple threads, use a mutex:
use Mutex;
use render;
static ZPL_MUTEX: = new;
How It Works
At build time, zpl-rs automatically downloads the appropriate prebuilt libzpl shared library for your platform from GitHub releases. The library is then linked dynamically.
You can override the version with the LIBZPL_VERSION environment variable:
LIBZPL_VERSION=0.2.0
License
MIT