GithubHelp home page GithubHelp logo

pdf417's Introduction

crates.io

PDF417 generated on esp32-s3 and displayed on a SSD1306 OLED screen

PDF417 Barcode generator

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.

Usage

Installation

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"

Generating a PDF417

Before you can generate a PDF417 barcode you should consider:

  1. The capacity of the barcode (maximum number of codewords).
  2. The level of error correction (0-8)
  3. The dimensions of the barcode (number of rows and columns)

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.

Data Segments

You can multiple data segments (aka encoding modes) on a single barcode. The available types are:

  • numeric: efficient encoding of 44+ digit numbers
  • ascii: efficient encoding of text (alphanumeric + punctuation) with support for non-displyable ASCII values which are encoded as raw bytes.
  • bytes: binary data as bytes

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.

Documentation

More documentation is available at docs.rs.

Contribution & Feedback

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!

License

pdf417 is available under the MIT license. See the LICENSE file for more info.

pdf417's People

Contributors

sofiman avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.