List of usage examples for java.awt.print PrinterException PrinterException
public PrinterException(String msg)
From source file:com.floreantpos.jasperreport.engine.print.JRPrinterAWT.java
/** * *///from w w w. j a va2 s.co m 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, new Integer(pageIndex)); exporter.exportReport(); } catch (JRException e) { if (log.isDebugEnabled()) log.debug("Print failed.", e); throw new PrinterException(e.getMessage()); } return Printable.PAGE_EXISTS; }
From source file:com.openbravo.pos.util.JRPrinterAWT411.java
/** * */// w w w. j a v a2s.co m public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (Thread.currentThread().isInterrupted()) { 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; }
From source file:com.openbravo.pos.util.JRPrinterAWT.java
/** * *///from www . j av a 2 s.c o m public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) throws PrinterException { if (Thread.currentThread().isInterrupted()) { 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(jasperReportsContext); 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; }
From source file:net.sf.jasperreports.engine.print.JRPrinterAWT.java
/** * *//* w w w. j av a2 s . co m*/ 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(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput(); output.setGraphics2D((Graphics2D) graphics); exporter.setExporterOutput(output); SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration(); configuration.setPageIndex(pageIndex); exporter.setConfiguration(configuration); exporter.exportReport(); } catch (JRException e) { if (log.isDebugEnabled()) { log.debug("Print failed.", e); } throw new PrinterException(e.getMessage()); //NOPMD } return Printable.PAGE_EXISTS; }
From source file:org.sanjose.util.JRPrinterAWT.java
/** * *//* w w w . java 2 s . c om*/ 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; }