1
0
Fork
You've already forked krilla-rxing
0
Render barcodes (QR Codes, Aztec, Data Matrix, etc) using rxing into a krilla Surface (PDF)
  • Rust 100%
Dominic 9227b12b1f
All checks were successful
Rust / readme (push) Successful in 11s
Rust / rustfmt (push) Successful in 1m3s
Rust / test (push) Successful in 2m14s
Release version 0.1.1
2026年01月24日 15:56:32 +01:00
.forgejo/workflows
cli Release version 0.1.1 2026年01月24日 15:56:32 +01:00
src
.gitignore
Cargo.lock Release version 0.1.1 2026年01月24日 15:56:32 +01:00
Cargo.toml Release version 0.1.1 2026年01月24日 15:56:32 +01:00
LICENSE
README.md Release version 0.1.1 2026年01月24日 15:56:32 +01:00
rustfmt.toml

krilla-rxing License: EUPL-1.2 krilla-rxing on crates.io krilla-rxing on docs.rs Source Code Repository

krilla-rxing extends the PDF creation library krilla with support for drawing barcodes based on the rxing library. This library aims to make barcode creation easy while optimising the PDF strokes s.t. the output file is as small as possible.

CLI

If all you need is a tool that creates a PDF for you, take a look at qrcode2pdf. Contrary to the name of the crate, it comes with a tool for all barcode formats supported by this library.

To create a PDF containing a QR Code, you can run

qrcode2pdf -o barcode.pdf https://codeberg.org/msrd0/krilla-rxing/src/branch/main/cli

Library

If you want to embed barcodes into your existing PDF-writing code, there are two APIs you can use. The simplest way is to call draw_qr_code on krilla’s Surface:

usekrilla_rxing::SurfaceExtas_;constPDF_UNITS_PER_MM: f32 =72.0/25.4;// draw a 10 x 10 cm QR Code at the top left of the surface
surface.draw_qr_code("https://codeberg.org/msrd0/krilla-rxing",Point::from_xy(0.0,0.0),100.0*PDF_UNITS_PER_MM).expect("Failed to draw QR Code");

Some other barcode are not necessarily square, and you might want to know the height of the barcode. In these cases, you need to create the barcode and then draw it using the draw_barcode function:

usekrilla_rxing::{Barcode,SurfaceExtas_};constPDF_UNITS_PER_MM: f32 =72.0/25.4;// draw a 10 x 10 cm PDF417 barcode at the top left of the surface
letbarcode_width=100.0*PDF_UNITS_PER_MM;letbarcode=Barcode::new_pdf417("https://codeberg.org/msrd0/krilla-rxing",barcode_width).expect("Failed to create PDF417 barcode");letbarcode_height=barcode.height();surface.draw_barcode(&barcode,Point::from_xy(0.0,0.0));