asee / pdf417

A Ruby wrapper for the PDF417 barcode library
MIT License
15 stars 20 forks source link

Generate different barcode with the Gem #10

Closed bonol closed 6 years ago

bonol commented 6 years ago

Hi there,

I using this Gem to generate PDF417 barcode png. It works as expected, though the output image is different from those generated by online barcode generators. Just wondering if there is any other variance to this barcode format or if there is anything I need to be aware of when setting up the option arguments. Thanks.

Here is an example generated by the gem and the code for it. generated_with_gem PDF417.new(barcode_text,aspect_ratio: 0.9).to_png(margin: 0, x_scale: 1, y_scale: 28)

And here is another example from the online generator with same data. by_online_generator

jamesprior commented 6 years ago

As far as I know, those are both PDF417 compliant barcodes. There are some differences between them but I think that is all about the options set on the left hand side of the online generator. The data mode, error correction level, row and column count will all change the barcode. Visually, one thing I note in the online example is that many of the rows are similar which suggests that for the length of data you're encoding you don't need 30 rows.

The gem will try to get a best row and column fit based on the data. I remember that it always uses one data mode but I forget what mode that is. Lastly, it has a default error correction level but I forget what that one is too.

The y scale in your ruby gem example is probably larger than it needs to be too. Maybe try 2 or 3?

As for what else to be aware of with the option arguments, I've always gone with 'scannable' as my top goal which depends a lot on the scanners you'll be using, the paper, and the environment they'll be used in. If it's a rough environment where the barcode can get obscured or destroyed a high error correction would be great. If it's on a small part that is protected from smudges then you'd want something smaller. It will probably take some experimentation to find the best fit.

bonol commented 6 years ago

Thanks James! I think you are right. At the end of day, it's all about if the barcode is 'scannable'. Will do some experiments.