3 of 9 Barcode
Brian K. White
brian at aljex.com
Tue Oct 27 19:41:05 PDT 2015
On 10/27/2015 3:56 PM, Chris S. via Filepro-list wrote:
>
>
> All,
> filePro 5.8Windows environment.
> This most likely has been addressed, but I am looking for a way to embed barcodes directly into my reports. I want to maybe use a downloadable software font to load onto an HP laser/desk jet printer if that is possible. I would like to be able to set it up in filePro's printer maintenance so that I can use a code in output to turn on/off barcode functions. Anyone know of any that are free?
> Thank you in advance for any help this list can provide.
> Chris
That is doable exactly as you imagine. We've done it since decades ago.
There are also other approaches like post-processing the print file with
a gnu barcode program like foobar.
From foobar.c comments:
UNIX command line example to print a 3-of-9 barcode for "123AC":
echo "A pretty [FOOBAR;DATA=*123AC*] example" | foobar | lp -d myprinter
You can see that would be pretty easy to drop into an output form, but
them you just have to print to-file and post-processs the file, or maybe
make a separate printer definition in fp that pipes through foobar, or
add foobar to the printer interface script in the spooler... Lots of way
to skin the cat.
And actaully today there are much better utils that do everything all
kinds of codes including qr codes. This "foobar" is a tiny simple c
program from 1999. There is also gnu-barcode and Zint
http://directory.fsf.org/wiki/Barcode
http://sourceforge.net/projects/zint/?source=navbar
I also did it one time by using a postscript barcode program. There is a
gpl barcode program written entirely in postscript.
http://bwipp.terryburton.co.uk/
I don't remember why that was an advantage in that case, maybe because
it allowed positioning and sizing, or maybe because it handled some
special barcode format that nothing else did? I don't remember. But you
just include this blob of ps in your print job,
print plain text from filepro, no pcl codes!, and in the print job you
insert these commands to print whatever kind of barcode you need, size,
style, position, data, etc, and any postscript printer prints it. In
that case I actually ran the final postscript output through ghostscript
to output pcl on the server, and sent the pcl to the printers instead of
the ps, because although the printers could all print ps, it turned out
to be a lot faster to have the server convert the ps to pcl and send the
pcl to the printer, than to just send the ps to the printer.
Your first question, putting the pcl soft font into a print code and
printing pcl from filepro is the simplest, most bulletproof way, but
less flexible. You have to pick a particular font file that has the
right code, prints at the right size, includes or does not include the
human-readable characters. If you change any of those then you have to
change which font file to load. And if you're using an encoding that
requires checksum digits or other encoding, you have to do that yourself
in processing, whereas barcode generator programs usually do that kind
of stuff for you. And it's just pcl. You'd have to then run the pcl
through ghostpdl to get a pdf or some other kind of printer. (but then
again, ghostpdl exists, so you could)
You have to buy the fonts from someone. There are at least a couple
companies selling them. I have been using these forever:
http://www.barcodingfonts.com/barcode-pcl-fonts.htm
It includes directions for how to load the font to the printer from dos
or unix, how to include it in a print job, and how to use it in a print
job. It was a little complicated figuring out the pcl codes at first,
but the info was all there in the included help files.
More recently I found these, same idea:
http://www.morovia.com/
I am using micr fonts for checks from here, not barcodes, but they have
barcodes too.
The prices and the licensing obligations might just make it worth your
while to dig into the post-processing approach, since then the software
is all 100% gpl and it's legal to redistribute it without worrying about
violating any license.
But to use the font, you don't have to change your printer config or
spooler setup at all. You can do it all 100% from within filepro and an
ordinary output format.
You just make a print code that includes %"/path/to/font.pcl"
like:
611 ■ $1b *c31D %"/u/aljex/bc/BR360H62.USP" $1b *c31D $1b *c5F ■ install
bc31 3of9 36pt 6.2cpi hr ■
This uploads the font file pro the printer, tells the printer to store
it as "font number 31". You stick that in the top-left corner of the
output format, or in the init code in the F8 options...
You know, I just found a whole notes file I had previously written up
just for this. This uses the Elfring fonts above. Here:
filepro-barcodes-pcl.txt
=============================================================================
=== Printing Bar Codes ===
This is a work in progress.
Step 5 should be able to be removed with some improvement to step 3.
More barcode fonts and documentation are in /u/aljex/bc/ .
brian at aljex.com
The overall process goes like this:
1) Figure out which barcode font you need.
2) Load the font into the printer once per print job.
3) Construct a dummy variable with the barcode data in processing.
4) Place the dummy on the output format.
5) Place some font fixup print codes immediately after the dummy.
How to do each of the above:
------------------------------------------------------------------------------
1) Figure out which font.
First you have to figure out which barcode font you will need, based on the
following properties:
type of barcode: 3of9, 2of5, 2of5-interleaved, upc, postnet, ocr
height: in points, 18pt, 36pt, 48pt, etc, 36pt = 1/2 inch
width: in characters per inch, 4.6cpi, 6.2cpi, etc...
human-readable: include regular characters also, or bare barcode.
orientation: portrait or landscape
Right now every barcode font in the print code table is a portrait mode
version.
However we also have a landscape version of each one which we can add to the
table if needed.
Consult the comments in the hplaser.prt print code table starting at
code 601
to see which of the available barcode fonts most closely matches the
type/size/shape/variant you want.
Example: For code 3of9, 1/2 inch high, 6 characters per inch,
with human-readable characters included, portrait mode orientation,
That would be print code 611, which installs the font as font ID 31.
You need to remember the 31 later.
------------------------------------------------------------------------------
2) Install the font during job-init.
In the output format F8-Options init sequence, put the code for the normal
init sequence plus the code to install the barcode font(s).
Using the example above this would be: %3 %611
------------------------------------------------------------------------------
3) Assemble the barcode data in processing.
You can't have leading/trailing spaces in the barcode, so you need to
build a
string in a variable in processing that has the pcl code to select the
barcode
font, plus the data, plus the pcl code to switch back to a normal font.
The barcode data needs to be:
select_bc_font { start_char { data { stop_char { select_normal_font
Since bar codes are large and odd-sized, it's easiest to deal with them like
graphics, where you save & restore the cursor position just before &
after the
image or in this case the bar code. And on your output format you place the
variable in the bottom-left corner of the space where the bar code
should go.
So you also want to add the push & pop pcl codes to above:
push { bc_font { start { data { stop { normal_font { pop
The pcl code to select a font by ID is "Esc(##X"
The pcl code to select the standard font is "Esc(10U"
The pcl code to push (save cursore position) is "Esc&f0S"
The pcl code to pop (restore cursore position) is "Esc&f1S"
For 3of9 barcodes, the start and stop characters are both "*"
So the filepro processing to build the various pcl codes is:
If: ' select font 31 (barcode) ; select standard font
Then: fb = chr("27"){"(31X" ; fs = chr("27"){"(10U"
If: ' pcl push ; pcl pop
Then: pu = chr("27"){"&f0S" ; po = chr("27"){"&f1S"
Assuming you want the font above, and assuming the data is a pro number in
real field 26, then the filepro processing to build the entire string and
place it in variable BC would be:
If:
Then: bc = pu { fb { "*" { 26 { "*" { fs { po
------------------------------------------------------------------------------
4) Place field *bc somewhere on your output format.
The barcode fonts are taller than normal , and the variable with the barcode
data includes cursor position save/restore codes.
So leave an empty rectangular space on the output format where the barcode
should go, and place the dummy variable *bc in the bottom-left corner of
that
rectangular area.
------------------------------------------------------------------------------
5) Add fix-up print codes immediately after *bc
To get the font back to the normal size after the barcode you may need to
insert print codes immediately after *bc. Print code 24 is already
inside the
variable bc, so not that one. But maybe 11, 15, and 30 or 31, or maybe
just 73.
------------------------------------------------------------------------------
==============================================================================
(end)
(code 73 in my hplaser.prt happens to be)
$1b (s0p10h0s0b4099T ■ * courier 10 pitch
There you go! At least using the soft font method.
The postscript method and the post-processing method are two entirely
different emails!
--
bkw
> Sent from my Verizon Wireless 4G LTE smartphone
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.celestial.com/pipermail/filepro-list/attachments/20151027/7d3f4b5d/attachment.html>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
More information about the Filepro-list
mailing list