HP laserJets Barcodes and CUPS

Paul Conklin paul.conklin at cerner.com
Thu Oct 20 17:48:29 PDT 2011


> > > > > > Ok, so does that mean that you would always want to send the SetBarCode or do you only want to send it when a certain condition is met (and if so what is that contidion)  basically there are a few ways to do it, I'm just trying to figure out if we need to use MIME types or not, if not, an interface script is easiest, if so than we'll have to define a custom MIME type, filter, and PPD (it's not as bad as it sounds)
> > > > > >
> > > > > > > > So, there is an easy way and a hard way.  do you only print barcodes to this or do you print regular stuff too?
> > > > > > > >
> > > > > > > > > I need to be able to send text files, from RHEL 5,  to a HP Laserjet printer containing Barcode ( 128 format ) information.
> > > > > > > > > Currently I have working, outside the application, the following
> > > > > > > > >
> > > > > > > > > lp -o raw  -d printername  SetBarCode
> > > > > > > > > which sets up the font on the printer ( all the control codes/escape sequences are in the SetBarCode file)
> > > > > > > > >
> > > > > > > > > Then to print
> > > > > > > > >
> > > > > > > > > lp -o raw -d printername Filename
> > > > > > > > >
> > > > > > > > > With the Filename having been formatted with a CR and LF at the end of each line
> > > > > > > > > and the escape sequences needed to select the Barcode font and return to normal font afterwards.
> > > > > > > > >
> > > > > > > > > The application developer has come back and said that the space he has for entering the print instruction is not long enough to contain all of this !!!
> > > > > > > > >
> > > > > > > > > And yes he could format up the SetBarCode + Filename into a single file BUt he still says that the -o raw ... causes the text to be too long.
> > > > > > > > >
> > > > > > > > > If I try to print the file without -o raw - I am told the file is empty
> > > > > > > > >
> > > > > > > > > Is there any way I can do this via a PPD file ? or a Filter ?
> > > > > > > > >
> > > > > > > > > All help appreciated
> > > > > > > > > Peter
> > > > > > > >
> > > > > > > Paul,
> > > > > > > I need to print both
> > > > > > > The idea is to provide a barcode from some information on the page, to allow parts tracking
> > > > > >
> > > > > Paul,
> > > > > The plan is to have text files sent to the printer, some of these may require a barcode to be printed. Currently I have managed to send a file to the printer which loads into Font 70 ( my choice of reference) a barcode font, which can be selected by means of Esc sequences in the print file.
> > > > > This I can do by setting the print to be 'raw' eg lp -d .... -o raw  filename
> > > > > The developer says that the command string is too long so I need to find another way of doing it.
> > > > > Also, I have a suspicion that the file to be printed will need to be fully formatted before it is sent as a 'raw' file.
> > > > > So here hoping you can help
> > > > > thanks
> > > > Ok, so one other question, do you have a PPD mounted to this printer already or is it just created as raw w/o a ppd.
> > > Paul,
> > > I have a ppd used for it : HP LaserJet 5000 Series Postscript (recommended)ie PPD for HP LaserJet 5000 Series
> > >
> > > I have also experimented with using it as a raw but the text loses its formatting, unless I edit the text file to put a CR/LF pair at the end of each line
> > >
> > Ok, so what is the condition that you would want to send the SetBarCode?  Always?  Only for a certain file type?  Only when something appears in the doc?.  I apologize for all the questions, just trying to put together the best course of action.
> Paul,
> no problem - I really appreciate all your help.
> OK The Barcodes will only be needed in some documents - I had assumed they would be triggered by the presence of the Control/Escape codes and text needed to be printed as a Barcode.
> Here is what I have managed to get working - using lp commands from Linux
>
> Cups modified to allow all codes to be sent
> ie /etc/cups/mime.convs modified
> application/octet-stream        application/vnd.cups-raw        0       -
>
> [and cupsd restarted ]
>
> Then
> lp -d <printer> SetBarCodes
>
> No errors and the Barcode font is now set to Font 70
>
> lp -d <printer> simple_text_file
> Prints OK
>
> lp -d <printer> text_file_with_barcodes
> Prints OK
>
> So in that much I think I have done it
> The printer is defined  via
> lpadmin -p <printer> -v lpd://<windows server>/HP_LaserJet_using_UniversalPS
>
> But the Application code does still not appear to work
> So if it is better, can I get CUPS to do the work on the Linux server ?
> Or is what I have done, the best way to do it ?


So, if you don't need to take advantage of the ability for cups to alter the printing language, you can probably fix this most easily with an interface script.  If you do need to take advantage of that ability, you'll have to do this in a couple of steps.  You'll need to define a custom mime type (Mike outlined that somewhat above)  You'll have to define a custom .convs as well and last, a custom filter that will either pass through the job or cat out the barcoded file and then the job.  I can outline this a little.  I have a specialized .types and .convs file.

types basically lets CUPS know how to "type" a file (i.e. identify inbound language) and give it a name.  .convs tells it how do we change it from one type to another.  last is the entry in the PPD.  it would be a cupsFilter line

*cupsFilter:    "application/securerx 0 troysecurerx"

that basically says left side is the type it needs, middle is "cost" right side is the name of the custom script.

If you can e-mail me an example print file, your PPD, and the barcode set up I can try and make a pass at it as time allows.




More information about the cups mailing list