ChristerH
asked on
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.getPrintJ ob(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();
}
}
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.getPrintJ
if(wpj != null)
{
Graphics g = wpj.getGraphics();
Font font = new Font("Courier", 0, 24);
g.setFont(font);
if(g != null)
{
g.drawString("Printing!!!"
g.dispose();
}
wpj.end();
}
}
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.
OutputStream os = new OutputStream("LPT1"); // win;
os.write("\n\rPrinting ...");
for other OSes - use the appripriate device.
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("Except ion occurred: " + e);
}
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("Except
}
Hi : vladi21,
If it is unix, what is the related command?
Thank you
ASKER
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?
FileOutputStream fos = new FileOutputStream("LPT1");
DataOutputStream dos = new DataOutputStream(fos);
dos.writeChars("Hello Star!\n");
dos.close();
Thanks!
What about the points?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
greedy vladi :)
we can at least split the points ...
we can at least split the points ...
heyhey_: You have a lot of points:)
I see - today is your answering day :)
why don't you go out for some night life ? :)
why don't you go out for some night life ? :)
Server's poor response
Not quick enough for browser.
Timed out, plum blossom.
Not quick enough for browser.
Timed out, plum blossom.
problems with provider... :)
ASKER