In using the HTML outputter I found that I wanted to show the barcode data in human readable format below the barcode. Almost all barcodes on things like SKUs etc. have this in case you don't have a scanner handy, you still can see what the barcode says. Adding this after the fact, at least in Rails, is a real hassle. You have to use javascript to modify the barcode <table> and turbolinks can make it flakey. It was much easier to do it in the generator itself where I already had access to the needed variable.
I added the option human_readable that is set like the class_name option.
@barcode.human_readable = true
This causes the stop method to add html code that creates a <tr></tr> below the barcode row. It takes the data from the barcode and divides the characters each into their own <td colspan="x"></td> element. x is generated by counting the number of </td> elements in the barcode row and dividing that by the character count of the barcode data. It places each character into those <td> elements and centers the text. The row is given a class that allows for styling.
Added a test to confirm human_readable option works.
All test passing except other generators which are skipped? Also the data-matrix test fails because I can't get semacode gem to install on my Mac.
In using the HTML outputter I found that I wanted to show the barcode data in human readable format below the barcode. Almost all barcodes on things like SKUs etc. have this in case you don't have a scanner handy, you still can see what the barcode says. Adding this after the fact, at least in Rails, is a real hassle. You have to use javascript to modify the barcode
<table>
and turbolinks can make it flakey. It was much easier to do it in the generator itself where I already had access to the needed variable.I added the option
human_readable
that is set like theclass_name
option.@barcode.human_readable = true
This causes the
stop
method to add html code that creates a<tr></tr>
below the barcode row. It takes the data from the barcode and divides the characters each into their own<td colspan="x"></td>
element. x is generated by counting the number of</td>
elements in the barcode row and dividing that by the character count of the barcode data. It places each character into those<td>
elements and centers the text. The row is given a class that allows for styling.Added a test to confirm
human_readable
option works.All test passing except other generators which are skipped? Also the data-matrix test fails because I can't get semacode gem to install on my Mac.
If the barcode is 2D then the option is ignored