Java printing on Star Micronics lineprinter ...

The model is called DP8340 ... but the main problem is that it is a lineprinter. The only way I know of getting data out on a printer is by creating a graphic area a draw stuff on it .... see below ...

So, if anybody know a way of solving this problem, please help me ...

Thanks in advance

/Chris


    private void OnClickPrint(Object source, Event e)
    {
        Toolkit tools = Toolkit.getDefaultToolkit();
        WPrintJob wpj = (WPrintJob)tools.getPrintJob(null, "Print?", null);
        if(wpj != null)
        {
            Graphics g = wpj.getGraphics();
            Font font = new Font("Courier", 0, 24);
            g.setFont(font);
            if(g != null)
            {
                g.drawString("Printing!!!", 50, 50);
                g.dispose();
            }
            wpj.end();
               
        }        
    }
ChristerHAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ChristerHAuthor Commented:
I think I forgot to tell you .. the problem is that the code I passed before does not work for lineprinters.
0
heyhey_Commented:
you can send text only information directly to the printer (port) ..

OutputStream os = new OutputStream("LPT1"); // win;
os.write("\n\rPrinting ...");

for other OSes - use the appripriate device.
0
vladi21Commented:
  If you simply want to print text, then write it to a file and print the
     file. Or open a filename that corresponds to the printer. On Windows,
     that is "LPT1" and the code looks like:

     try {
         FileOutputStream fos = new FileOutputStream("LPT1");
         PrintStream ps = new PrintStream(fos);
                 ps.print("Your string goes here");
                 ps.print("\f");
                 ps.close();
     } catch (Exception e) {
         System.out.println("Exception occurred: " + e);
     }
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

Ravindra76Commented:

Hi : vladi21,

 If it is unix, what is the related command?

Thank you
0
ChristerHAuthor Commented:
This works ok!

FileOutputStream fos = new FileOutputStream("LPT1");
DataOutputStream dos = new DataOutputStream(fos);
dos.writeChars("Hello Star!\n");
dos.close();

Thanks!

What about the points?
0
vladi21Commented:
Answer:

   If you simply want to print text, then write it to a file and print the
     file. Or open a filename that corresponds to the printer. On Windows,
     that is "LPT1" and the code looks like:

     try {
         FileOutputStream fos = new FileOutputStream("LPT1");
         PrintStream ps = new PrintStream(fos);
                 ps.print("Your string goes here");
                 ps.print("\f");
                 ps.close();
     } catch (Exception e) {
         System.out.println("Exception occurred: " + e);
     }
 
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
heyhey_Commented:
greedy vladi :)
we can at least split the points ...
0
vladi21Commented:
heyhey_: You have a lot of points:)
0
heyhey_Commented:
I see - today is your answering day :)

why don't you go out for some night life ? :)
0
heyhey_Commented:
Server's poor response
Not quick enough for browser.
Timed out, plum blossom.
0
vladi21Commented:
problems with provider... :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.