Pages

Tuesday, October 5, 2010

This Should Not Be This Difficult

I am trying to open a USB printer from Java.  I was just assuming that FileOutputStream os = new FileOutputStream("USB001") or something like that would do the trick.  Apparently not.

You may be wondering why I am opening a USB device directly.  Don't ask.  It is an ugly one-time hack because the label printer does not like PDF files--so I have to throw the printer's native crud at it (a bunch of binary codes, of course).  I need to print a vast number of labels...once.

UPDATE: If there is an easy way to open a USB printer from Java, I can't find it.  What I did find was a kludge, but it works.  Follow the directions at Bruce's Printing Pages to redirect LPT1: (the old parallel printer interface) to your USB printer.  Then FileOutputStream("LPT1:") lets you write to the USB printer.

No comments:

Post a Comment