/** * Transforms y coordinates from pixel space to character space. */ protected int calculateYCoord(int y) { return (int) (((long) pageHeight * y) / jasperPrint.getPageHeight()); }
protected void drawPageError(Graphics grx) { grx.setColor(Color.white); grx.fillRect(0, 0, jasperPrint.getPageWidth() + 1, jasperPrint.getPageHeight() + 1); }
public static long getImageSize(JasperPrint jasperPrint, float zoom) { int width = (int) (jasperPrint.getPageWidth() * zoom) + 1; int height = (int) (jasperPrint.getPageHeight() * zoom) + 1; return width * height; } }
public void setFitPageZoomRatio() { setRealZoomRatio(((float)pnlInScroll.getVisibleRect().getHeight() - 20f) / jasperPrint.getPageHeight()); }
/** * */ public static void exportFooter(JasperPrint jasperPrint, Writer writer) throws IOException { writer.write(" <w:sectPr>\n"); writer.write(" <w:pgSz w:w=\"" + Utility.twip(jasperPrint.getPageWidth()) + "\" w:h=\"" + Utility.twip(jasperPrint.getPageHeight()) + "\""); writer.write(" w:orient=\"" + (jasperPrint.getOrientation() == JRReport.ORIENTATION_LANDSCAPE ? "landscape" : "portrait") + "\""); writer.write("/>\n"); writer.write(" <w:pgMar w:top=\"0\" w:right=\"0\" w:bottom=\"0\" w:left=\"0\" w:header=\"0\" w:footer=\"0\" w:gutter=\"0\" />\n"); // writer.write(" <w:cols w:space=\"720\" />\n"); writer.write(" <w:docGrid w:linePitch=\"360\" />\n"); writer.write(" </w:sectPr>\n"); writer.write(" </w:body>\n"); writer.write("</w:document>\n"); }
protected void drawPageError(Graphics grx) { grx.setColor(Color.white); grx.fillRect(0, 0, viewerContext.getJasperPrint().getPageWidth() + 1, viewerContext.getJasperPrint().getPageHeight() + 1); }
/** * */ private void buildPageLayout(int reportIndex, JasperPrint jasperPrint) throws IOException { writer.write("<style:page-layout"); writer.write(" style:name=\"page_" + reportIndex + "\">\n"); writer.write("<style:page-layout-properties"); writer.write(" fo:page-width=\"" + XmlssUtil.translatePixelsToInchesRound(jasperPrint.getPageWidth()) +"in\""); writer.write(" fo:page-height=\"" + XmlssUtil.translatePixelsToInchesRound(jasperPrint.getPageHeight()) +"in\"");//FIXMEODT we probably need some actualHeight trick writer.write(" fo:margin-top=\"0in\"");//FIXMEODT useless? writer.write(" fo:margin-bottom=\"0in\""); writer.write(" fo:margin-left=\"0in\""); writer.write(" fo:margin-right=\"0in\""); switch (jasperPrint.getOrientation()) { case JRReport.ORIENTATION_LANDSCAPE: writer.write(" style:print-orientation=\"landscape\""); break; default: writer.write(" style:print-orientation=\"portrait\""); break; } writer.write("/>\n"); writer.write("</style:page-layout>\n"); }
protected Image getPageErrorImage() { Image image = new BufferedImage( (int) (jasperPrint.getPageWidth() * realZoom) + 1, (int) (jasperPrint.getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB ); Graphics2D grx = (Graphics2D) image.getGraphics(); AffineTransform transform = new AffineTransform(); transform.scale(realZoom, realZoom); grx.transform(transform); drawPageError((Graphics2D) grx); return image; }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { writer.write("<div style=\"position:relative;width:" + jasperPrint.getPageWidth() + "px;height:" + jasperPrint.getPageHeight() + "px;\">\n"); frameIndexStack = new ArrayList(); exportElements(page.getElements()); writer.write("</div>"); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ private void fitPage(){ float heightRatio = ((float)pnlInScroll.getVisibleRect().getHeight() - 20f) / jasperPrint.getPageHeight(); float widthRatio = ((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / jasperPrint.getPageWidth(); setRealZoomRatio(heightRatio < widthRatio ? heightRatio : widthRatio); }
public void setFitPageZoomRatio() { setRealZoomRatio(getPageCanvasHeight() / viewerContext.getJasperPrint().getPageHeight()); }
protected Image getPageErrorImage() { Image image = new BufferedImage( (int) (viewerContext.getJasperPrint().getPageWidth() * realZoom) + 1, (int) (viewerContext.getJasperPrint().getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB ); Graphics2D grx = (Graphics2D) image.getGraphics(); AffineTransform transform = new AffineTransform(); transform.scale(realZoom, realZoom); grx.transform(transform); drawPageError((Graphics2D) grx); return image; }
/** * Export to PNG * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception * @throws IOException IOException exception */ public SpecificTemplateExporterBuilderService toPng() throws JRException, IOException { BufferedImage pageImage = new BufferedImage(this.report.getPageWidth() + 1, this.report.getPageHeight() + 1, BufferedImage.TYPE_INT_RGB); JRGraphics2DExporter exporter = new JRGraphics2DExporter(); exporter.setExporterInput(new SimpleExporterInput(this.report)); SimpleGraphics2DExporterOutput exporterOutput = new SimpleGraphics2DExporterOutput(); exporterOutput.setGraphics2D((Graphics2D) pageImage.getGraphics()); exporter.setExporterOutput(exporterOutput); exporter.exportReport(); ImageIO.write(pageImage, "png", new FileOutputStream(new File(getTemplatePath().replace(extensionPattern, "png")))); return this; }
/** * */ protected void exportPage(JRPrintPage page) throws JRException { grx.setColor(Color.white); grx.fillRect( 0, 0, jasperPrint.getPageWidth(), jasperPrint.getPageHeight() ); grx.setColor(Color.black); grx.setStroke(new BasicStroke(1)); /* */ frameDrawer.draw(grx, page.getElements(), getOffsetX(), getOffsetY()); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ private Image printPageToImage(int pageIndex, float zoom) throws JRException { Image pageImage = new BufferedImage( (int)(jasperPrint.getPageWidth() * zoom) + 1, (int)(jasperPrint.getPageHeight() * zoom) + 1, BufferedImage.TYPE_INT_RGB ); JRGraphics2DExporter exporter = new JRGraphics2DExporter(); exporter.setParameter(JRExporterParameter.JASPER_PRINT, this.jasperPrint); exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics()); exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex)); exporter.setParameter(JRGraphics2DExporterParameter.ZOOM_RATIO, new Float(zoom)); exporter.exportReport(); return pageImage; }
protected void fitPage() { float heightRatio = getPageCanvasHeight() / viewerContext.getJasperPrint().getPageHeight(); float widthRatio = getPageCanvasWidth() / viewerContext.getJasperPrint().getPageWidth(); setRealZoomRatio(heightRatio < widthRatio ? heightRatio : widthRatio); }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { startPage = true; JRGridLayout layout = new JRGridLayout( nature, page.getElements(), jasperPrint.getPageWidth(), jasperPrint.getPageHeight(), globalOffsetX, globalOffsetY, null //address ); exportGrid(layout, null); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { JRGridLayout layout = new JRGridLayout( nature, page.getElements(), jasperPrint.getPageWidth(), jasperPrint.getPageHeight(), globalOffsetX, globalOffsetY, null //address ); exportGrid(layout, isWhitePageBackground); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { startPage = true; JRGridLayout layout = new JRGridLayout( nature, page.getElements(), jasperPrint.getPageWidth(), jasperPrint.getPageHeight(), globalOffsetX, globalOffsetY, null //address ); exportGrid(layout, null); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
protected void addBookmark(int level, String title, int x, int y) { Bookmark parent = bookmarkStack.peek(); while(parent.level > level - 1) { bookmarkStack.pop(); parent = bookmarkStack.peek(); } for (int i = parent.level + 1; i < level; ++i) { Bookmark emptyBookmark = new Bookmark(parent, parent.pdfOutline.getPdfDestination(), EMPTY_BOOKMARK_TITLE); bookmarkStack.push(emptyBookmark); parent = emptyBookmark; } Bookmark bookmark = new Bookmark(parent, x, jasperPrint.getPageHeight() - y, title); bookmarkStack.push(bookmark); }