First Class International label with small barcode that will not scan. |
I could not scan the code after printing, so I doubt that the Post Office would be able to. I tried to improve my printer settings, but it was still a no go. It might have been my cheap thermal labels off Amazon, but I still wanted them to work. Since I have a number of packages to send to Canada, I wanted this fixed. Since the Priority labels are acceptable to the USPS with the larger barcode, why not just use a larger barcode on First Class? There is enough room.
So that is what I did. Now, you can too.
ZPL is a simple text file that can be edited if you know the commands, which are so graciously provided by Zebra. Editing files manually is tedious and prone to error. Enter the Launcher built in to my Linux desktop (I use Linux Mint 17.1, an Ubuntu derivative). This could be made to work on OSX using the Automator. This is an extension of my previous post about printing ZPL files by dragging and dropping onto a Launcher.
Digging into the ZPL file of a First Class International label provided to me by the Shippo, an online shipping label provider, we find the line that describes the barcode:
^FO621,119^BY2^BCR,101,N,N,N,A^FDLN123456789US^FSCode breakdown:
- "621,119" is the X,Y position of the barcode in pixels
- "BY2" says that a barcode element is 2 pixels wide
- "BCR" tells us that it is a Code 128 barcode that is rotated (along the long axis of the label, rather than horizontal as it prints out)
- "101" is the height of the barcode in pixels
- "LN123456789US" is the actual value to be encoded in the barcode
When looking at a Priority Mail International label, it uses "BY3" so the barcode is 1.5 times wider, which is what we want. When we make the barcode wider, it will only grow in one direction, so we also need to move its position to keep it centered in the available space. I found that moving the position from 119 to 48 in the Y dimension filled out the space appropriately. So the following line would give me what I want:
^FO621,48^BY3^BCR,101,N,N,N,A^FDLN123456789US^FSThere is a command line tool, sed (or stream editor), that can be used to find and replace text strings in a file. If we incorporate this into the launcher from my previous post, we get the following:
bash -c "sed 's/621,119^BY2^BCR/621,48^BY3^BCR/g' <%f | lp -d ZPL_II_PrinterThis command searches through the ZPL file(s) that is(are) dragged onto the launcher looking for the string "621,119^BY2^BCR". If found, it replaces that string with "621,48^BY3^BCR". The output stream is then sent to the printer and it prints. I included more than what really needed to be modified ("119^BY2" with "48^BY3") because I want to reduce the likelihood of accidentally modifying a label that is not First Class International. The chances of that were already slim, but I am cautious.
This launcher can now be used for any label. If it is a First Class International label, it will print with a larger barcode that is more easily printed and scanned. If it is a different type of label, it will print out normally.
First Class International label modified with larger barcode. |