krilla-rxing 0.1.1

Render barcodes (QR Codes, Aztec, Data Matrix, etc) using rxing into a krilla Surface (PDF)
Documentation
# krilla-rxing ![License: EUPL-1.2]https://img.shields.io/badge/license-EUPL--1.2-blue [![krilla-rxing on crates.io]https://img.shields.io/crates/v/krilla-rxing]https://crates.io/crates/krilla-rxing [![krilla-rxing on docs.rs]https://docs.rs/krilla-rxing/badge.svg]https://docs.rs/krilla-rxing [![Source Code Repository]https://img.shields.io/badge/Code-On%20Codeberg-blue?logo=Codeberg]https://codeberg.org/msrd0/krilla-rxing

`krilla-rxing` extends the PDF creation library [`krilla`][__link0] with support for drawing
barcodes based on the [`rxing`][__link1] 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`][__link2].
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

```shell
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`][__link3] on krilla’s [`Surface`][__link4]:

```rust
use krilla_rxing::SurfaceExt as _;

const PDF_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`][__link5] function:

```rust
use krilla_rxing::{Barcode, SurfaceExt as _};

const PDF_UNITS_PER_MM: f32 = 72.0 / 25.4;

// draw a 10 x 10 cm PDF417 barcode at the top left of the surface
let barcode_width = 100.0 * PDF_UNITS_PER_MM;
let barcode =
	Barcode::new_pdf417("https://codeberg.org/msrd0/krilla-rxing", barcode_width)
		.expect("Failed to create PDF417 barcode");
let barcode_height = barcode.height();
surface.draw_barcode(&barcode, Point::from_xy(0.0, 0.0));
```


 [__cargo_doc2readme_dependencies_info]: ggGkYW0CYXSEG_W_Gn_kaocAGwCcVPfenh7eGy6gYLEwyIe4G6-xw_FwcbpjYXKEG4n9htPCNZj_G3QBZDQPvMDnG1k9jnjfDmAvG_0PPjBYx0zEYWSDgmZrcmlsbGFlMC42LjCDbGtyaWxsYS1yeGluZ2UwLjEuMWxrcmlsbGFfcnhpbmeCZXJ4aW5nZTAuOC4z
 [__link0]: https://crates.io/crates/krilla/0.6.0
 [__link1]: https://crates.io/crates/rxing/0.8.3
 [__link2]: https://codeberg.org/msrd0/krilla-rxing/src/branch/main/cli
 [__link3]: https://docs.rs/krilla-rxing/0.1.1/krilla_rxing/?search=SurfaceExt::draw_qr_code
 [__link4]: https://docs.rs/krilla/0.6.0/krilla/?search=surface::Surface
 [__link5]: https://docs.rs/krilla-rxing/0.1.1/krilla_rxing/?search=SurfaceExt::draw_barcode