rxing-core / rxing

cRustacean Crossing
https://crates.io/crates/rxing
Apache License 2.0
198 stars 19 forks source link

encoding pdf417_compact has extra white space #31

Closed agkyunromb closed 1 year ago

agkyunromb commented 1 year ago

my code

use rxing::helpers::save_file;
use rxing::common::BitMatrix;
use rxing::pdf417::encoder::Dimensions;
use rxing::pdf417::PDF417Writer;
use rxing::BarcodeFormat::PDF_417;
use rxing::EncodeHintType::{ERROR_CORRECTION, MARGIN, PDF417_COMPACT, PDF417_DIMENSIONS};
use rxing::EncodeHintValue::{ErrorCorrection, Margin, Pdf417Compact, Pdf417Dimensions};
use rxing::EncodingHintDictionary as Hint;
use rxing::Writer;

fn main(){
    let ring = ring_code("test", 103, 270);
    save_file("test.jpg", &ring).unwrap();
}

fn ring_code(contents: &str, width: i32, height: i32) -> BitMatrix {
    let writer = PDF417Writer::default();
    let dimensions = Dimensions::new(2, 2, 70, 70);
    let mut hints = Hint::new();
    hints.insert(ERROR_CORRECTION, ErrorCorrection("6".to_string()));
    hints.insert(PDF417_DIMENSIONS, Pdf417Dimensions(dimensions));
    hints.insert(PDF417_COMPACT, Pdf417Compact("true".to_string()));
    hints.insert(MARGIN, Margin(("5").to_string()));

    writer
        .encode_with_hints(contents, &PDF_417, width, height, &hints)
        .unwrap()
}

result

test as you can see it have extra white space

it should be

test

34

hschimke commented 1 year ago

Fixed by #34 fixed this issue

hschimke commented 1 year ago

This fix appears in v0.4.6, currently uploading to cargo