use of javax.print.event.PrintJobAdapter in project jdk8u_jdk by JetBrains.
the class PrintSEUmlauts method main.
public static void main(String[] args) throws Exception {
GraphicsEnvironment.getLocalGraphicsEnvironment();
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
String mime = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();
StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, mime);
if (factories.length == 0) {
System.out.println("No print service found.");
return;
}
FileOutputStream output = new FileOutputStream("out.ps");
StreamPrintService service = factories[0].getPrintService(output);
SimpleDoc doc = new SimpleDoc(new PrintSEUmlauts(), DocFlavor.SERVICE_FORMATTED.PRINTABLE, new HashDocAttributeSet());
DocPrintJob job = service.createPrintJob();
job.addPrintJobListener(new PrintJobAdapter() {
@Override
public void printJobCompleted(PrintJobEvent pje) {
testPrintAndExit();
}
});
job.print(doc, new HashPrintRequestAttributeSet());
}
Aggregations