Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Barcode not working
10-15-2009, 06:38 AM
Post: #1
Barcode not working
#

I wish to add a Code-128 barcode to a document. Unfortunately it is not one of the built in barcodes, so I need to use an embedded font. That works alright, except for one problem:
The text to be displayed as a barcode needs to be converted to a new text string which then displays the correct barcode pattern for the original text. I can do that. Some of the characters in the converted text have the high bit on, in particular the leader and terminator characters appear to be 0xAA and 0xAD on all Code-128 barcodes. The pdf shows the correct leader but not the correct terminator - it uses the barcode pattern for 0x2D (hyphen) instead of the barcode for 0xAD ("soft hyphen"). That was using the standard code page and encoding method. On changing the encoding method I got more problems, so none of the available encoding methods worked.

Perhaps there needs to be a "no encoding" or "raw" method available - would that work?
Or would using a different code page work, although the choices available don't suggest it would make any difference?
Or is there some other technique that would work?
Or do you know of some 3rd part product out there which will convert the text into an image file, which can then be added to the pdf?

Cheers
Pedrocelli
#


Pedrocelli,

I'm not quite understanding what the issue is as far as the hyphens and encoding. Are you saying the text you're passing is being encoding differently from what you want? Maybe an example PDF and probably the font would help me see what's going on so I can make a suggestion. There *may* be some encoding options that can be placed on the embedded font but I'd need to see what's going on first.

Thanks,
Mike Bernardo
FyTek, Inc.
#


Try adding encoding="MacExpertEncoding" to your font tag. I did a test and it seems to have worked.

Example: <FONT FACE=Barcode SRC=128M24L4.TTF SIZE=36 encoding="MacExpertEncoding">

From the PDF reference: Despite its name, it is not a platform-specific encoding; however, only certain fonts have the appropriate character set for use with this encoding.

Thanks,
Mike Bernardo
FyTek, Inc.
#


I tried the MacExpertEncoding and I thought it had worked - the PDF now shows the correct barcode when viewed on the screen. However, when I print it using Adobe Reader it loses most of the barcode and so does not scan at all. I took a screenshot of the PDF displayed on screen then printed that, and I was able to scan that barcode correctly off the paper.

Attached is a sample output PDF demonstrating the problem. This shows a) a generated barcode, b) the text value of that barcode and c) an image file of a screenshot of the same barcode from Notepad. The two barcodes look the same on the screen, but not when printed.

Why would Adobe Reader display and print the barcode differently? What is the next step?

Cheers
Pedrocelli

* BEEP1001bc.pdf

#


. . . for the record, this happens whether using the Windows version or the Linux version of Text2PDF. The example provided was produced using the Windows version.
Pedrocelli
#


Very odd. I'm not sure on this other than the code in Reader is designed to work with that particular encoding but not the print driver. I tried printing as an image and am getting the same thing.

See if the attached helps - I created a sort of sampler of what each character is in the font. It seems as only the last character is causing an issue when you are not specifying the encoding. Perhaps it's just a matter of setting a different character from 0xAD. I have the decimal, hex value and the barcode character from 32 to 255. Just run the attached through text2pdf and check the results. You can do a search/replace if you need to modify the font it uses.

Thanks,
Mike Bernardo
FyTek, Inc.

* btest.txt

#


Yes, that one character 0xAD gives the same pattern as 0x2D (hyphen). The other characters around it all seem to have unique patterns, so it looks like just that one character is altered.

The problem is that Code-128 barcodes always finish with character 0xAD so that particular character will always need to be displayed/printed correctly. The conversion process may also produce other "high-bit" characters and whatever they are they need to be displayed without modification. Substitution is not an option.

Why does a font need to have an encoding at all? Why can't the font selection use a "raw" encoding? If I cut and paste the converted text for a string into Notepad, then change the font to the Code-128 barcode font, it gives the correct barcode and it also prints it correctly. Why can't a PDF do the same - just display the characters in the font verbatim?

Pedrocelli
#


See if this one prints and scans OK - it seems to work for me. I set the AD character in the encoding in this case to a softhyphen. The problem is Reader is wanting to convert the AD to a hyphen and thus messing up the barcode. I also had to set A6 to "brokenbar" (via a code mod so you won't be able to create a PDF this way just yet). If it works I'll have to check on some of the other characters and possibly add them. I'm not sure what the full set of characters (above ASCII 128) you need for this font.

Thanks,
Mike Bernardo
FyTek, Inc.

* barcode.pdf

#


That prints and scans correctly, thanks, Mike.

I'm not sure what other "high-bit" characters can occur that aren't in this test - I will consult with a colleague and get back to you.

Pedrocelli
#


The characters that may be needed for Code128 are 0xA1 to 0xAD inclusive, ie: these 13 characters here (if they can be recorded here)
¡¢£¤¥¦§¨©ª«¬­

I can't see the last one in my browser, but it seems to be there. The last one is used at the end of every Code128 barcode, and the preceding three are the start codes so one of them is used at the start of every Code128 barcode.

I'm still curious to know if PDFs can have text in them with a "raw encoding" or no encoding, so that the whole 256 ASCII 8-bit characters are printed exactly as they are, like Notepad seems to do.

Pedrocelli
#


I put the change in place so download a new copy at your convenience - you'll need to set CODEPAGE="BC" on the font tag though (no encoding). This is just to tell it not to convert the 0xAD to 0x2D.

Like this: <FONT FACE=Barcode SRC=128M24L4.TTF SIZE=36 CODEPAGE="BC">

Thanks,
Mike Bernardo
FyTek, Inc.
#


Bingo! That worked - thanks Mike.
Find all posts by this user
Quote this message in a reply
11-20-2009, 10:18 AM
Post: #2
RE: Barcode not working
this is like i encounter on Nokia barcode reader not working with Zs. RevK.



________________________
custom screen print
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: