|
Hi Group,
Just a note of thanks for all the responses - they really helped!
I've got it working now. It was actually more of a driver problem than
anything else. As an aside, I might add that a printer that simply swallows
data without so much as a blinking light and refuses to even attempt to
print it seems a bit... Something. <grin>
Still not done - I think I can improve the looks of the output by
using the Actual Driver and using graphics - we'll see if I get time.
Anyway - thanks to everybody that pitched in.
For the archives, here is what I came up with...
try {
//os = new FileOutputStream("USB001");
os = new FileOutputStream("USB001");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
PrintStream ps = new PrintStream(os);
.
.
.
StringBuffer sb = new StringBuffer();
sb.append("N\n");
sb.append("M1\n\n");
.
.
.
sb.append("P1\n\f");
prt("Final:"+sb.toString(),2);
DocFlavor flavor = DocFlavor.INPUT_STREAM.AUTOSENSE;
PrintRequestAttributeSet aset = new
HashPrintRequestAttributeSet();
/* locate a print service that can handle it */
PrintService pservices = PrintServiceLookup
.lookupDefaultPrintService();
/* create a print job for the chosen service */
DocPrintJob pj = pservices.createPrintJob();
/* * Create a Doc object to hold the print data.
* Since the data is in a byte array,
* an input stream needs to be obtained from the byte array
*/
byte[] myByte = sb.toString().getBytes();
ByteArrayInputStream bis = new ByteArrayInputStream(myByte);
Doc doc = new SimpleDoc(bis, flavor, null);
try {
/* print the doc as specified */
pj.print(doc, aset);
} catch (PrintException e2) {
e2.printStackTrace();
}
try {
ps.flush();
os.flush();
} catch (IOException e1) {
e1.printStackTrace();
}
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.