PrintService[ ] services = PrinterJob.lookupPrintServices();
Why do I get a syntax error or is there a better script example ?
Thank you
------------------------------------------------------------------
complete script example:
// lookup printers available on this machine
PrintService[] services = PrinterJob.lookupPrintServices();
// loop through the printers
for (int index = 0; index < services.length; index++)
{
// find the Microsoft XPS Document Writer
if (services[index].getName().equalsIgnoreCase("Microsoft XPS Document Writer"))
{
// create a new PrinterJob
PrinterJob pjob = PrinterJob.getPrinterJob();
// set the print service as the Microsoft XPS Document Writer
pjob.setPrintService(services[index]);
// create a new HashPrintRequestAttributeSet
HashPrintRequestAttributeSet attributes = new HashPrintRequestAttributeSet();
// set the output file as a destination
attributes.add(new Destination(new File("c:/output.xps").toURI()));
// set the attributes to the printerjob
pjob.print(attributes);
// MyPrintable will have to be defined to implement the print method
pjob.setPrintable(new MyPrintable(), new PageFormat());
}
}