public static void imprimirDirecto(String url, int i) {
FileInputStream archivo;
try {
archivo =new FileInputStream(url);
DocFlavor formato = DocFlavor.INPUT_STREAM.PNG;
Doc documento = new SimpleDoc(archivo, formato, null);
PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
//----las opciones que me interesan configurar de la impresora
aset.add(MediaSizeName.NA_LETTER);//el tamaño de la hoja (carta)
// aset.add(MediaSizeName.ISO_A4);
aset.add(new Copies(1));
//aset.add(Chromaticity.MONOCHROME);
// aset.add(OrientationRequested.PORTRAIT);
// discover the printers that can print the format according to the
// instructions in the attribute set
PrintService[] services = PrintServiceLookup.lookupPrintServices(formato, aset);
// Create a print job from one of the print services
if (services.length > 0) {
DocPrintJob job = services[i].createPrintJob();
try {
job.print(documento, aset);
} catch (PrintException pe) {}
}
}catch(Exception e){
}
}