Hi all,
I was trying to select tray while printing my pdf file. Below is the
exaple code i am working,
PDDocument document = null;
try
{
document = new PDDocument();
document = PDDocument.load("Fatura.pdf");
PrinterJob printJob = PrinterJob.getPrinterJob();
PrintService service =
PrintServiceLookup.lookupDefaultPrintService();
if (service != null)
{
msg = " % selected printer " + service.getName();
showMsg(msg);
printJob.setPrintService(service);
HashPrintRequestAttributeSet attrSet = new
HashPrintRequestAttributeSet();
attrSet.add(MediaSizeName.ISO_A4);
attrSet.add(MediaTray.BOTTOM);
attrSet.add(new Copies(1));
printJob.print(attrSet);
msg = "Print is sent";
showMsg(msg);
}
else
{
msg = " % No printer found ";
showMsg(msg);
}
}
catch (IOException ioe)
{
showMsg(ioe.toString());
}
catch (PrinterException pe)
{
showMsg(pe.toString());
}
finally
{
try
{
if (document != null)
{
document.close();
}
}
catch (IOException ioe)
{
showMsg(ioe.toString());
}
}
When i call printJob.print(attrSet), i dont see any printing
activity. But whenever i call document.silentPrint(printJob) i can see
that the pdf file is sent. I want to set the printing attributes
before sending the pdf file to printer. How can i do it?
Thanx.
--
Oğuz Yarımtepe
www.loopbacking.info