Crates.io | pdf417 |
lib.rs | pdf417 |
version | 0.2.1 |
source | src |
created_at | 2023-09-23 18:22:00.879222 |
updated_at | 2023-10-16 08:21:32.845096 |
description | No-std PDF417 encoder |
homepage | |
repository | https://github.com/Sofiman/pdf417/ |
max_upload_size | |
id | 981405 |
size | 154,363 |
A no-std and no-alloc PDF417 encoder for embedded applications (also works for std). This library implements mutliple encoding modes for numbers, strings and bytes according to the specification. You can also customize the rendering of the barcodes (size, storage and inverted) and supports both Truncated PDF417 and MicroPDF417.
pdf417 is available on crates.io
Use the cargo add command:
cargo add pdf417
or add the crate in your Cargo.toml:
[dependencies]
pdf417 = "0"
Before you can generate a PDF417 barcode you should consider:
Here is an no-std and no alloc example to generate a PDF417 barcode:
use pdf417::*;
const COLS: u8 = 3;
const ROWS: u8 = 5;
const WIDTH: usize = pdf417_width!(COLS);
const HEIGHT: usize = pdf417_height!(ROWS);
// High-level encoding
let mut input = [0u16; (ROWS * COLS) as usize];
let (level, _) = PDF417Encoder::new(&mut input, false)
.append_ascii("Hello, world!").fit_seal().unwrap();
// Rendering
let mut storage = [false; WIDTH * HEIGHT];
PDF417::new(&input, ROWS, COLS, level).render(&mut storage[..]);
If you need a bigger barcode, you can control the size of the modules (see the documentation) using the pdf417_width and pdf417_height macros.
You can multiple data segments (aka encoding modes) on a single barcode. The available types are:
An additional UTF-8 mode is available which allows encoding of UTF-8 strings using an ECI identifier and byte encoding mode (note that this encoding takes significantly more space than the ASCII mode).
See the different methods available on
PDF417Encoder
struct.
More documentation is available at docs.rs.
If you have any feedback, please open an issue. If you encounter any bugs or unwanted behaviour, please open an issue.
This projet is open to contributions, feel free to submit your pull requests!
pdf417 is available under the MIT license. See the LICENSE file for more info.