Printing
Version vom 18. Mai 2011, 16:47 Uhr von Onlineprog (Diskussion | Beiträge) (simple pcl programming by java)
- Simple PCL print commands as java application
import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.PrintWriter; public class SimplePrintPCL { public static void main(final String[] args) throws FileNotFoundException { //final String device = "prn:"; // prn, lpt1, com1, ttyS0 ... final String device = "\\\\pcname\\shareprtname"; // printer share on windows final OutputStream fos = new FileOutputStream(device); final PrintWriter pw = new PrintWriter(fos); final String esc = Character.toString((char) 27); // escape final String formfeed = Character.toString((char) 12); // form feed, next page System.out.println("Ready..."); System.out.println("Device: " + device); pw.println(esc + "%-12345X"); // UEL Command (exit language) pw.println(esc + "E"); // Printer Reset Command. pw.println(esc + "&l1S"); // Duplex pw.println("Seite 1/6 duplex formfeed ->"); pw.println(formfeed); // form feed, soft page break pw.println("Seite 2/6"); pw.println(formfeed); // form feed, soft page break pw.println(esc + "&l0S"); // Simplex pw.println("Seite 3/6 simplex formfeed ->"); pw.println(formfeed); // form feed, soft page break pw.println("Seite 4/6"); pw.println(formfeed); // form feed, soft page break pw.println(esc + "&l1S"); // Duplex pw.println("Seite 5/6 duplex &l26A ->"); pw.println(esc + "&l26A"); // form feed, hard page break (new paper/letter) pw.println("Seite 4/4"); pw.println(esc + "E"); // Printer Reset Command. pw.println(esc + "%-12345X"); // UEL Command (exit language) pw.close(); System.out.println("Done."); } }