|
Spec-Zone .ru
спецификации, руководства, описания, API
|
PrintService []services =
PrintServiceLookup.lookupPrintServices(DocFlavor.SERVICE_FORMATTED.PRINTABLE,
null);
The printing
application implements the Printable interface. To create the Doc,
use SimpleDoc, passing this in for the printData, the
service-formatted DocFlavor constant for the DocFlavor, and an
optional attribute set:
Doc doc = new SimpleDoc(this, DocFlavor.SERVICE_FORMATTED.PRINTABLE, null);Create the DocPrintJob, and submit it to the service:
DocPrintJob pj = service[0].createPrintJob(); pj.print(doc);See Example: Print2DGraphics.java for the complete application.
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE
StreamPrintServiceFactory []factories =
StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor,
"application/postscript"));
if (factories.length == 0) {
System.err.println("No suitable factories");
System.exit(0);
}
try{
FileOutputStream fos = new FileOutputStream("out.ps");
StreamPrintService sps = factories[0].getPrintService(fos);
}
Doc doc = new SimpleDoc(this, flavor, null);
sps.createPrintJob().print(doc);
See Example:
Print2DtoStream.java for the complete application