*/
public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException
{
if (Thread.interrupted())
{
throw new PrinterException("Current thread interrupted.");
}
pageIndex += pageOffset;
if ( pageIndex < 0 || pageIndex >= jasperPrint.getPages().size() )
{
return Printable.NO_SUCH_PAGE;
}
try
{
JRGraphics2DExporter exporter = new JRGraphics2DExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint);
exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, graphics);
exporter.setParameter(JRExporterParameter.PAGE_INDEX, Integer.valueOf(pageIndex));
exporter.exportReport();
}
catch (JRException e)
{
if (log.isDebugEnabled())
{
log.debug("Print failed.", e);
}
throw new PrinterException(e.getMessage()); //NOPMD
}
return Printable.PAGE_EXISTS;
}