Not sure why it's happening, but why not add a break command when you find the printer you want to print to (after you sent the print command, of course)? Also, Java arrays are zero-based, so the initial value of x should probably be 0, not 1.
On Wed, Nov 20, 2013 at 4:26 PM, Gyenes István <[email protected]> wrote: > Hi All! > > I'm new in BDFBox. > I try to print one page to specified tray, but it is make an endless > printing loop. I do something wrong or it is a bug in the library? > My source code is: > PDDocument pdf = PDDocument.load("c:\\Java\\nb74_projects\\lpu\\AISB08. > pdf"); > PrintService[] ps = PrinterJob.lookupPrintServices(); > for (int x=1; x<ps.length; x++) { > System.out.println(ps[x].getName()); > if (ps[x].getName().compareTo("Canon Generic PCL6 > Driver")==0) { > PrinterJob pj = PrinterJob.getPrinterJob(); > pj.setPrintService(ps[x]); > PrintRequestAttributeSet pset = new > HashPrintRequestAttributeSet(); > pset.add(MediaTray.TOP); > pj.setPrintable(pdf.getPrintable(0)); > pj.print(pset); > } > } > > Big thanks for any help! > Stephen Gyenes >

