Printing in Java
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mukadam_Nusrat
Posted On:   Tuesday, May 14, 2002 08:34 PM

Hi, All I am doing printing in my application using a java class...the printing is working fine but there is a small problem..I am using a CBM 231 Partial cut Printer liek the one used in restaurants that automatically cuts ur paper....bu in my application after it prints, it doesnt cut the paper..i have tried other printing ways and it cuts the paper so ti is not a problem with the printer..it is a problem with my code i guess..can anyone help...code is below :- import java.io.*; import sun.audio.*; //import the sun.audio package import java.applet.AudioClip; import java.applet.*; import java.net.URL; public class lpt { public static void test (String tid,Strin   More>>

Hi, All

I am doing printing in my application using a java class...the printing is working fine but there is a small problem..I am using a CBM 231 Partial cut Printer liek the one used in restaurants that automatically cuts ur paper....bu in my application after it prints, it doesnt cut the paper..i have tried other printing ways and it cuts the paper so ti is not a problem with the printer..it is a problem with my code i guess..can anyone help...code is below :-

import java.io.*;
import sun.audio.*; //import the sun.audio package
import java.applet.AudioClip;
import java.applet.*;
import java.net.URL;

			

public class lpt {

public static void test (String tid,String name, int qty) {
try {
Today td = new Today();
FileOutputStream os = new FileOutputStream("\\Ps_apex_1\ps_lpt2");
//wrap stream in "friendly" PrintStream
PrintStream ps2 = new PrintStream(os);
String date = td.datecal();
String time = td.timecal();
String datetime = date + " " + time;
String order = qty +" "+"*"+" "+ name;
//print text here
ps2.println(datetime);
ps2.println("Table Number: "+tid);
ps2.println("");
ps2.println(order);
ps2.println("_________________________________________");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
//form feed -- this is important
//Without the form feed, the text will simply sit
// in print buffer until something else gets printed.
ps2.print("f");
//flush buffer and close
ps2.flush();
ps2.close();


}
catch (Exception e) {
System.out.println("Exception occurred: " + e);
}
}//end test 1

public static void test2 (String tid,String name, int qty) {
try {

Today td = new Today();
FileOutputStream os = new FileOutputStream("\\Ps_apex_1\ps_lpt1");
//wrap stream in "friendly" PrintStream
PrintStream ps2 = new PrintStream(os);
String date = td.datecal();
String time = td.timecal();
String datetime = date + " " + time;
String order = qty +" "+"*"+" "+ name;
//print text here
ps2.println(datetime);
ps2.println("Table Number: "+tid);
ps2.println("");
ps2.println(order);
ps2.println("_________________________________________");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
ps2.println("");
//form feed -- this is important
//Without the form feed, the text will simply sit
// in print buffer until something else gets printed.
ps2.print("
f");
//flush buffer and close
ps2.close();
}
catch (Exception e) {
System.out.println("Exception occurred: " + e);
}
}//end test2

public static void sound() {
File f = new File("c:\images\agegyoza.wav");
AudioClip theSound;
try {
theSound = Applet.newAudioClip(f.toURL());
} catch (java.net.MalformedURLException e) {
theSound = null;
}
if (theSound != null) {
theSound.play();
}
}

}//end class

   <<Less
About | Sitemap | Contact