× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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 thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 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.