class StreamPrintingOrientation implements Printable { /** *Constructor
*/ public StreamPrintingOrientation() { super();
} /** *Startstheapplication.
*/ publicstaticvoid main(java.lang.String[] args) {
StreamPrintingOrientation pd = new StreamPrintingOrientation();
PrinterJob pj = PrinterJob.getPrinterJob();
HashPrintRequestAttributeSet prSet = new HashPrintRequestAttributeSet();
PrintService service = null;
FileOutputStream fos = null;
File f = null, f1 = null;
String mType = "application/postscript";
try {
f = new File("streamexample.ps");
fos = new FileOutputStream(f);
StreamPrintServiceFactory[] factories = PrinterJob.lookupStreamPrintServices(mType); if (factories.length > 0)
service = factories[0].getPrintService(fos);
if (service != null) {
System.out.println("Stream Print Service "+service);
pj.setPrintService(service);
} else { thrownew RuntimeException("No stream Print Service available.");
}
} catch (Exception e) {
e.printStackTrace();
}
pj.setPrintable(pd);
prSet.add(OrientationRequested.LANDSCAPE);
prSet.add(new Copies(3));
prSet.add(new JobName("orientation test", null));
System.out.println("open PrintDialog.."); if (pj.printDialog(prSet)) { try {
System.out.println("\nValues in attr set passed to print method");
Attribute attr[] = prSet.toArray(); for (int x = 0; x < attr.length; x ++) {
System.out.println("Name "+attr[x].getName()+" "+attr[x]);
}
System.out.println("About to print the data ..."); if (service != null) {
System.out.println("TEST: calling Print");
pj.print(prSet);
System.out.println("TEST: Printed");
}
} catch (PrinterException pe) {
pe.printStackTrace();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.