You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Oguz Yarimtepe <co...@gmail.com> on 2010/05/03 15:48:13 UTC

tray printing not working

I am using JAVA print API and PDFBox to print a PDF file from the tray
of the printer. The printer is Xerox Phaser 3428. Below is the code
part i am using to choose the tray and send print. My application is
an applet.. Changing attrSet.add(MediaTray.BOTTOM); to TOP or MANUAL
didn't effect the te way that printer select the tray. It always got
the paper from TOP tray. Any idea what the reason is?

PDDocument document = null;
try
{
document = new PDDocument();
URL url = new URL("http://localhost/test/Fatura.pdf");
document = PDDocument.load(url);
PrinterJob printJob = PrinterJob.getPrinterJob();

PrintService service = PrintServiceLookup.lookupDefaultPrintService();
if (service != null)
{
msg = " % selected printer " service.getName();
strBuffer.append(msg);
repaint();
showMsg(msg);

printJob.setPrintService(service);

HashPrintRequestAttributeSet attrSet = new HashPrintRequestAttributeSet();
attrSet.add(MediaSizeName.ISO_A4);
attrSet.add(MediaTray.BOTTOM);
attrSet.add(new Copies(1));

printJob.setPageable(document);

printJob.print(attrSet);

//document.print(printJob);

msg = " % Print is sent";
strBuffer.append(msg);
repaint();
showMsg(msg);

document.close();
}
else
{
msg = " % No printer found ";
strBuffer.append(msg);
repaint();
showMsg(msg);
}
}
catch (IOException ioe)
{
//strBuffer.append("%" ioe.toString());
//repaint();
showMsg(ioe.toString());
}


-- 
Oğuz Yarımtepe
www.loopbacking.info