ZPL and mixing subsets - zpl

we have a new client that needs there bar code created with mixing subset C and A. We are using the ZPL language to print to a zebra printer and I've followed the Zebra programming guide but cant get the output I'm after. I need the bar code to read:
9931265099999891DJS12345670100060020
My code looks like this:
^BY3^BCN,200,Y,N,N
^FD>;9931265099999891>7DJS>512345670100060020^FS
and outputs this with some other characters that are not even ascii:
9931265099999891 S7M &* ...
Can someone tell what I'm doing wrong
thank you

I figured out my own problem....
Thanks Magoo for taking time to look at my question...
When switching to subcode A you cannot just use the letters you want to display but must use a table (in the ZPL programming guide) that shows the characters that represent the characters that need to be displayed. I used this to get it to work, notice after changing to sub-code A (>7) you need duo characters to represent the characters you actually want displayed i.e..
36 = D
42 = J
51 = S
^BY2^BCN,200,Y,N,Y,N
^FD>;9931265099999891>7364251>512345670100060020^FS
Hope my solution helped someone else
cheers all

I got this to work using
^BCN,200,Y,N,N ^FD>;9931265099999891>6DJS1>52345670100060020^FS
Note that this switches to code B instead of A.
The final string of digits is an odd number of characters and it seemed to lop off the final character in code C. The string I constructed uses an even number of digits for each of the code-C sections and the remaining characters in code-B.
I could not get code-A to work at all, but I'm using an old printer (A300) which may not have the latest firmware.

Related

How to encode a TAB character in a Code128 barcode using only raw ZPL

In the past, we've used ZPL to create Code39 barcodes with a TAB character encoded in the middle using something similar to the following:
*USERNAME$IPASSWORD*
The $I in the middle gets translated to a TAB by the barcode scanners we use.
Now we have a need to do the same thing, but using Code128. With Code39, all the text needs to be uppercase (unless you're using Code39Extended, which supports lowercase letters). Because some of the data that is going to be encoded will be lowercase, we need to use Code128 B for most of the barcode, switching to Code128 A in the middle to encode the TAB character, then back to Code128 B for the final part.
Looking through the "ZPL II Programming Guide", it should be as easy as:
>:username>7{TAB}>6PA55w0rd
The >: at the beginning sets the subset to B, the >7 changes the subset to A, and the >6 changes the subset back to B. The problem I'm having (and haven't found a solution after almost a week of searching) is: How do I encode a TAB character using only text?
Use the ^FH (field hexidecimal encoding) command immediately prior to your field data. Based on your example:
^FH_^FD>:username>7_09>6PA55w0rd^FS
Where the underscore '_' is used as the escape character and 09 is the hex value for tab.
Also note that if the chosen escape character appears in the user name or password, you will need to escape it as well.
I tried what Mark Warren suggested, but unfortunately, it didn't work. It did, however, get me looking back through the ZPL II Programming Guide and I found the following, which I had overlooked before:
Code 128, Subsets A and C are programmed in pairs of digits, 00 to 99, in the field data string.
...
In Subset A, each pair of digits results in a single character being encoded in the bar code...
So, since 73 equates to a TAB in Subset A, I tried the following:
>:username>773>6PA55w0rd
And it worked!

How to chop ruby string having a random number

My string is - main_string = 'FA117RWD-20 ABC Program (version 10.0)'
In this string I just want to read FA117RWD-20 and in this string version is random which will be coming from somewhere, its version 10 right now it can be version 20 at some other time also the part that I want to read i.e. FA117RWD-20 will also be coming from somewhere randomly so is not of fix length, basically I want to chop everything that is coming after this string. How should I do it?
Thanks
main_string = 'FA117RWD-20 ABC Program (version 10.0)'
main_string[/\S+/]
#=> "FA117RWD-20"
The regular expression matches one or more characters that are not whitespace.
Another way is the following1.
main_string[0..main_string.index(' ')-1]
1 One can use three dots and write main_string[0...main_string.index(' ')], but I prefer to always use two dots.
you can just use #split
'FA117RWD-20 ABC Program (version 10.0)'.split(' ').first

GS1-128 barcode with ZPL does not put the AI in ()

i was expecting this command
^FO15,240^BY3,2:1^BCN,100,Y,N,Y,^FD>:>842011118888^FS
to generate a
(420) 11118888
interpretation line, instead it generates
~n42011118888
anyone have idea how to generate the expected output?
TIA!
Joey
If the firmware is up to date, D mode can be used.
^BCo,h,f,g,e,m
^XA
^FO15,240
^BY3,2:1
^BCN,100,Y,N,Y,D
^FD(420)11118888^FS
^XZ
D = UCC/EAN Mode (x.11.x and newer firmware)
This allows dealing with UCC/EAN with and without chained
application identifiers. The code starts in the appropriate subset
followed by FNC1 to indicate a UCC/EAN 128 bar code. The printer
automatically strips out parentheses and spaces for encoding, but
prints them in the human-readable section. The printer automatically
determines if a check digit is required, calculate it, and print it.
Automatically sizes the human readable.
The ^BC command's "interpretation line" feature does not support auto-insertion of the parentheses. (I think it's safe to assume this is partly because it has no way of determining what your data identifier is by just looking at the data provided - it could be 420, could be 4, could be any other portion of the data starting from the first character.)
My recommendation is that you create a separate text field which handles the logic for the parentheses, and place it just above or below the barcode itself. This is the way I've always approached these in the past - I prefer this method because I have direct control over the font, font size, and formatting of the interpretation line.

ZPL - Barcode Missing a digit when printed

I am trying to print a Code 128 barcode on a label using the following the piece of ZPL with a Zebra ZP 450 printer:
^BY3^BCN,112,N^FO090,660^FD>;>89102100^FS
I'm expecting the barcode to scan as "9102100". However, when I scan the printed barcode, it reads as "910210" -- cutting off the final digit.
If I change the last digit, it is still cut off. But if I add more digits onto the end, e.g. "9102100357", the barcode correctly reads as "9102100357".
Why am I "losing" a digit in this particular case?
The >; inside of your ^FD block is telling the code 128 barcode to go into a subset (subset C in this case) which forces the data in the barcode to be numeric pairs (00 - 99). Any data that is not supplied in numeric pairs is ignored. If you put a letter in there, it will ignore that pair. In your case 9102100 has an odd number of numbers, so it ignores the last one. If for example, you add another 0, it will put all the letters in the barcode.
The ;> which puts the barcode in Subset C is not the default. Subset B or :> is the default which will allow any character to be encoded in the barcode. So you can replace the ;> with :>, or just remove the ;> entirely, and it will print out properly.
Check out the ^BC documentation in the ZPL programming manual for more information about Code 128 subsets and data validation
See pg 92 of the ZPL Programming Guide.
This issue may have been fixed in the firmware update, see below:
Example: This is an example with the mode parameter set to D*:
^XA
^PON
^LH0,0
^BY2,2.5,145
^FO218,343
^BCB,,Y,N,N,D
^FD(91)0005886>8(10)0000410549>8(99)05^FS
^XZ
D* — When trying to print the last Application Identifier with an odd number of characters, a problem
existed when printing EAN128 bar codes using Mode D. The problem was fixed in firmware version
V60.13.0.6."

Putting spaces back into a string of text with unreliable space information

I need to parse some text from pdfs but the pdf formatting results in extremely unreliable spacing. The result is that I have to ignore the spaces and have a continuous stream of non-space characters.
Any suggestions on how to parse the string and put spaces back into the string by guessing?
I'm using ruby. Or should I say I'musingruby?
Edit: I've pulled the text out using pdf-reader. Some of the pdf files are nicely formatted and some are not. An example of text mixed with positioning:
.7aspe-5.5cts-715.1o0.6f-708.5f-0.4aces-721.4that-716.3are-720.0i-1.8mportant-716.3in-713.9soc-5.5i-1.8alcommunica6.6tion6.3.-711.6Althoug6.3h-708.1m-1.9od6.3els-709.3o6.4f-702.8f5.4ace-707.9proc6.6essing-708.2haveproposed-611.2ways-615.5to-614.7deal-613.2with-613.0these-613.9diff10.4erent-613.7tasks,-611.9it-617.1remainsunclear-448.0how-450.7these-443.2mechanisms-451.7might-446.7be-447.7implemented-447.2in-450.3visualOne-418.9model-418.8of-417.3human-416.4face-421.9processing-417.5proposes-422.7that-419.8informa-tion-584.5is-578.0processed-586.1in-583.1specialised-584.7modules-577.0(Breen-584.4et-582.9al.,-582.32002;Bruce-382.1and-384.0Y92.0oung,-380.21986;-379.2Haxby-379.9et-380.5al.,-
and if I print just string data (I added returns at the end of each line to keep it from
messing up the layout here:
'Distinctrepresentationsforfacialidentityandchangeableaspectsoffacesinthehumantemporal
lobeTimothyJ.Andrews*andMichaelP.EwbankDepartmentofPsychology,WolfsonResearchInstitute,
UniversityofDurham,UKReceived23December2003;revised26March2004;accepted27July2004Availab
leonline14October2004Theneuralsystemunderlyingfaceperceptionmustrepresenttheunchanging
featuresofafacethatspecifyidentity,aswellasthechangeableaspectsofafacethatfacilitates
ocialcommunication.However,thewayinformationaboutfacesisrepresentedinthebrainremainsc
ontroversial.Inthisstudy,weusedfMRadaptation(thereductioninfMRIactivitythatfollowsthe
repeatedpresentationofidenticalimages)toaskhowdifferentface-andobject-selectiveregionsofvisualcortexcontributetospecificaspectsoffaceperception'
The data is spit out by callbacks so if I print each string as it is returned it looks like this:
'The
-571.3
neural
-573.7
system
-577.4
underly
13.9
ing
-577.2
face
-573.0
perc
13.7
eption
-574.9
must
-572.1
repr
20.8
esent
-577.0
the
unchangin
14.4
g
-538.5
featur
16.5
es
-529.5
of
-536.6
a
-531.4
face
'
On examination it looks like the true spaces are large negative numbers < -300 and the false spaces are much smaller positive numbers. Thanks guys. Just getting to the point where i am asking the question clearly helped me answer it!
Hmmmm... I'd have to say that guessing is never a good idea. Looking at the problem root cause and solving that is the answer, anything else is a kludge.
If the spacing is unreliable from the PDF, how is it unreliable? The PDF viewer needs to be able to reliably space the text so the data is there somewhere, you just need to find it.
EDIT following comment:
The idea of parsing the file using a dictionary (your only other option really, apart from randomly inserting spaces and hoping for the best) and inserting spaces at identified word boundaries (a real problem when dealing with punctuation, plurals that don't alter the base word i.e. plural, etc) would, I believe, be a much greater programming challenge than correctly parsing the PDF in the first place. After all, PDF is clearly defined whereas English is somewhat wooly.
Why not look down the route of existing solutions like ps2ascii in linux, call the function from your Ruby and pick up the result.
PDF doesn't only store spaces as space characters, but also uses layout commands for spacing (so it doesn't print a space, but moves the "pen" to the right). Perhaps you should have a look at the PDF reference (the big PDF on the bottom of the site), Chapter 9 "Text" should be what you're looking for.
EDIT: After reading your comment to Lazarus' answer, this doesn't seem to be what you're looking for. I think you should try to get a word list from somewhere and try to split your text using it. A good strategy would be to do that using recursion, because for example:
"meandyou"
The first word could be "me" or "mean", but if you try "mean", "dyou" doesn't make sense, so it will be "me", same for the next word that could be "a" or "an" or "and", only "and" makes sense.
If it were me I'd go back to the source PDFs and try a different method of extracting the text, such as iText (for Java) or maybe some kind of PDF-to-HTML to text conversion software method.

Resources