// Paper Attributes: media-printable-area, orientation-requested, media
PrintRequestAttributeSet prats = m_layout.getPaper().getPrintRequestAttributeSet();
// add: copies, job-name, priority
if (m_info.isDocumentCopy() || m_info.getCopies() < 1)
prats.add (new Copies(1));
else
prats.add (new Copies(m_info.getCopies()));
Locale locale = Language.getLoginLanguage().getLocale();
prats.add(new JobName(m_printFormat.getName(), locale));
prats.add(PrintUtil.getJobPriority(m_layout.getNumberOfPages(), m_info.getCopies(), true));
try
{
// PrinterJob
PrinterJob job = getPrinterJob(m_info.getPrinterName());
// job.getPrintService().addPrintServiceAttributeListener(this);
job.setPageable(m_layout.getPageable(false)); // no copy
// Dialog
try
{
if (m_info.isWithDialog() && !job.printDialog(prats))
return;
}
catch (Exception e)
{
log.log(Level.WARNING, "Operating System Print Issue, check & try again", e);
return;
}
// submit
boolean printCopy = m_info.isDocumentCopy() && m_info.getCopies() > 1;
ArchiveEngine.get().archive(m_layout, m_info);
PrintUtil.print(job, prats, false, printCopy);
// Document: Print Copies
if (printCopy)
{
log.info("Copy " + (m_info.getCopies()-1));
prats.add(new Copies(m_info.getCopies()-1));
job = getPrinterJob(m_info.getPrinterName());
// job.getPrintService().addPrintServiceAttributeListener(this);
job.setPageable (m_layout.getPageable(true)); // Copy
PrintUtil.print(job, prats, false, false);
}