net.sf.jasperreports.engine.PrintPageFormat Java Examples
The following examples show how to use
net.sf.jasperreports.engine.PrintPageFormat.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JRPrinterAWT.java From nordpos with GNU General Public License v3.0 | 6 votes |
/** * */ public Image printPageToImage(int pageIndex, float zoom) throws JRException { PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); Image pageImage = new BufferedImage( (int)(pageFormat.getPageWidth() * zoom) + 1, (int)(pageFormat.getPageHeight() * zoom) + 1, BufferedImage.TYPE_INT_RGB ); JRGraphics2DExporter exporter = new JRGraphics2DExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput(); output.setGraphics2D((Graphics2D)pageImage.getGraphics()); exporter.setExporterOutput(output); SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration(); configuration.setPageIndex(pageIndex); configuration.setZoomRatio(zoom); exporter.setConfiguration(configuration); exporter.exportReport(); return pageImage; }
Example #2
Source File: JRViewerPanel.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
protected Image getPageErrorImage() { PrintPageFormat pageFormat = viewerContext.getPageFormat(); Image image = new BufferedImage( (int) (pageFormat.getPageWidth() * realZoom) + 1, (int) (pageFormat.getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB ); AffineTransform transform = new AffineTransform(); transform.scale(realZoom, realZoom); Graphics2D grx = (Graphics2D) image.getGraphics(); try { grx.transform(transform); drawPageError(grx); } finally { grx.dispose(); } return image; }
Example #3
Source File: JRXmlExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ protected void exportPart(Integer pageIndex, PrintPart part) throws JRException, IOException { xmlWriter.startElement(JRXmlConstants.ELEMENT_part); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageIndex, pageIndex); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, part.getName()); PrintPageFormat pageFormat = part.getPageFormat(); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageWidth, pageFormat.getPageWidth()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageHeight, pageFormat.getPageHeight()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_topMargin, pageFormat.getTopMargin()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_leftMargin, pageFormat.getLeftMargin()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_bottomMargin, pageFormat.getBottomMargin()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_rightMargin, pageFormat.getRightMargin()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_orientation, pageFormat.getOrientation(), OrientationEnum.PORTRAIT); xmlWriter.closeElement(); }
Example #4
Source File: DocxTableHelper.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
/** * */ protected DocxTableHelper( JasperReportsContext jasperReportsContext, Writer writer, CutsInfo xCuts, boolean pageBreak, PrintPageFormat pageFormat, JRPrintElementIndex frameIndex ) { super(jasperReportsContext, writer); this.xCuts = xCuts; this.cellHelper = new DocxCellHelper(jasperReportsContext, writer); this.paragraphHelper = new DocxParagraphHelper(jasperReportsContext, writer, pageBreak); this.pageFormat = pageFormat; this.frameIndex = frameIndex; }
Example #5
Source File: OoxmlUtils.java From jasperreports with GNU Lesser General Public License v3.0 | 6 votes |
public static PaperSizeEnum getSuitablePaperSize(PrintPageFormat pageFormat) { if (pageFormat != null && pageFormat.getPageWidth() != 0 && pageFormat.getPageHeight() != 0) { long mmPageWidth = Math.round(((double)pageFormat.getPageWidth() / 72d) * 25.4); long mmPageHeight = Math.round(((double)pageFormat.getPageHeight() / 72d) * 25.4); for (PaperSizeEnum paperSize : PaperSizeEnum.values()) { if ( ((paperSize.getWidth() == mmPageWidth) && (paperSize.getHeight() == mmPageHeight)) || ((paperSize.getHeight() == mmPageWidth) && (paperSize.getWidth() == mmPageHeight)) ) { return paperSize; } } } return PaperSizeEnum.UNDEFINED; }
Example #6
Source File: JRViewer.java From nordpos with GNU General Public License v3.0 | 6 votes |
protected Image getPageErrorImage() { PrintPageFormat pageFormat = getPageFormat(); Image image = new BufferedImage( (int) (pageFormat.getPageWidth() * realZoom) + 1, (int) (pageFormat.getPageHeight() * realZoom) + 1, BufferedImage.TYPE_INT_RGB ); Graphics2D grx = (Graphics2D) image.getGraphics(); AffineTransform transform = new AffineTransform(); transform.scale(realZoom, realZoom); grx.transform(transform); drawPageError(grx); return image; }
Example #7
Source File: HtmlExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected void exportPage(JRPrintPage page) throws IOException { Tabulator tabulator = new Tabulator(tableFilter, page.getElements()); tabulator.tabulate(getOffsetX(), getOffsetY()); HtmlReportConfiguration configuration = getCurrentItemConfiguration(); boolean isIgnorePageMargins = configuration.isIgnorePageMargins(); if (!isIgnorePageMargins) { PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); tabulator.addMargins(pageFormat.getPageWidth(), pageFormat.getPageHeight()); } Table table = tabulator.getTable(); boolean isWhitePageBackground = configuration.isWhitePageBackground(); if (isWhitePageBackground) { setBackcolor(Color.white); } CellElementVisitor elementVisitor = new CellElementVisitor(); TableVisitor tableVisitor = new TableVisitor(tabulator, elementVisitor); exportTable(tableVisitor, table, isWhitePageBackground, true); if (isWhitePageBackground) { restoreBackcolor(); } JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
Example #8
Source File: StyleBuilder.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public void buildPageLayout(int pageFormatIndex, PrintPageFormat pageFormat) { writer.write("<style:page-layout"); writer.write(" style:name=\"page_" + pageFormatIndex + "\">\n"); writer.write("<style:page-layout-properties"); writer.write(" fo:page-width=\"" + LengthUtil.inchRound4Dec(pageFormat.getPageWidth()) +"in\""); writer.write(" fo:page-height=\"" + LengthUtil.inchRound4Dec(pageFormat.getPageHeight()) +"in\"");//FIXMEODT we probably need some actualHeight trick writer.write(" fo:margin-top=\"0in\"");//FIXMEODT if first cell on page is for frame (nested table), this forcing of margins to zero does not work writer.write(" fo:margin-bottom=\"0in\""); writer.write(" fo:margin-left=\"0in\""); writer.write(" fo:margin-right=\"0in\""); switch (pageFormat.getOrientation()) { case 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"); }
Example #9
Source File: JRGraphics2DExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ protected void exportPage(Graphics2D grx, int pageIndex) throws JRException { List<JRPrintPage> pages = jasperPrint.getPages(); JRPrintPage page = pages.get(pageIndex); PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); if (whitePageBackground) { grx.setColor(Color.white); grx.fillRect( 0, 0, pageFormat.getPageWidth(), pageFormat.getPageHeight() ); } grx.setColor(Color.black); grx.setStroke(new BasicStroke(1)); /* */ drawVisitor.getFrameDrawer().draw(grx, page.getElements(), getOffsetX(), getOffsetY()); JRExportProgressMonitor progressMonitor = getCurrentItemConfiguration().getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
Example #10
Source File: JROdtExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ protected void exportPage(JRPrintPage page) throws JRException, IOException { startPage = true; ReportExportConfiguration configuration = getCurrentItemConfiguration(); PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); JRGridLayout layout = new JRGridLayout( nature, page.getElements(), pageFormat.getPageWidth(), pageFormat.getPageHeight(), configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY(), null //address ); exportGrid(layout, null); JRExportProgressMonitor progressMonitor = configuration.getProgressMonitor(); if (progressMonitor != null) { progressMonitor.afterPageExport(); } }
Example #11
Source File: JRViewer.java From nordpos with GNU General Public License v3.0 | 5 votes |
/** * */ private void fitPage(){ PrintPageFormat pageFormat = getPageFormat(); float heightRatio = ((float)pnlInScroll.getVisibleRect().getHeight() - 20f) / pageFormat.getPageHeight(); float widthRatio = ((float)pnlInScroll.getVisibleRect().getWidth() - 20f) / pageFormat.getPageWidth(); setRealZoomRatio(heightRatio < widthRatio ? heightRatio : widthRatio); }
Example #12
Source File: JasperReportsUtils.java From JuniperBot with GNU General Public License v3.0 | 5 votes |
public static BufferedImage printToImage(JasperPrint jasperPrint, int pageIndex, float zoom) throws JRException { JRGraphEnvInitializer.initializeGraphEnv(); PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); int rasterWidth = (int) Math.ceil(pageFormat.getPageWidth() * zoom); int rasterHeight = (int) Math.ceil(pageFormat.getPageHeight() * zoom); BufferedImage pageImage = new BufferedImage( rasterWidth, rasterHeight, BufferedImage.TYPE_INT_ARGB ); Graphics2D graphics = (Graphics2D) pageImage.getGraphics(); SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput(); output.setGraphics2D(graphics); SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration(); configuration.setPageIndex(pageIndex); configuration.setZoomRatio(zoom); configuration.setWhitePageBackground(false); JRGraphics2DExporter exporter = new JRGraphics2DExporter(DefaultJasperReportsContext.getInstance()); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); exporter.setExporterOutput(output); exporter.setConfiguration(configuration); exporter.exportReport(); graphics.dispose(); return pageImage; }
Example #13
Source File: JRPrinterAWT.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
/** * */ public Image printPageToImage(int pageIndex, float zoom) throws JRException { PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); int rasterWidth = (int) Math.ceil(pageFormat.getPageWidth() * zoom); int rasterHeight = (int) Math.ceil(pageFormat.getPageHeight() * zoom); Image pageImage = new BufferedImage( rasterWidth, rasterHeight, BufferedImage.TYPE_INT_RGB ); Graphics imageGraphics = pageImage.getGraphics(); Graphics graphics = imageGraphics.create(); //filling the image background here because JRGraphics2DExporter.exportPage uses the page size //which can be smaller than the image size due to Math.ceil above graphics.setColor(Color.white); graphics.fillRect(0, 0, rasterWidth, rasterHeight); JRGraphics2DExporter exporter = new JRGraphics2DExporter(jasperReportsContext); exporter.setExporterInput(new SimpleExporterInput(jasperPrint)); SimpleGraphics2DExporterOutput output = new SimpleGraphics2DExporterOutput(); output.setGraphics2D((Graphics2D) imageGraphics); exporter.setExporterOutput(output); SimpleGraphics2DReportConfiguration configuration = new SimpleGraphics2DReportConfiguration(); configuration.setPageIndex(pageIndex); configuration.setZoomRatio(zoom); configuration.setWhitePageBackground(false); exporter.setConfiguration(configuration); exporter.exportReport(); return pageImage; }
Example #14
Source File: JRViewerPanel.java From jasperreports with GNU Lesser General Public License v3.0 | 5 votes |
protected void fitPage() { PrintPageFormat pageFormat = viewerContext.getPageFormat(); float heightRatio = getPageCanvasHeight() / pageFormat.getPageHeight(); float widthRatio = getPageCanvasWidth() / pageFormat.getPageWidth(); setRealZoomRatio(heightRatio < widthRatio ? heightRatio : widthRatio); }
Example #15
Source File: JRViewer.java From nordpos with GNU General Public License v3.0 | 4 votes |
protected void drawPageError(Graphics grx) { PrintPageFormat pageFormat = getPageFormat(); grx.setColor(Color.white); grx.fillRect(0, 0, pageFormat.getPageWidth() + 1, pageFormat.getPageHeight() + 1); }
Example #16
Source File: JRViewer.java From nordpos with GNU General Public License v3.0 | 4 votes |
/** */ protected void refreshPage() { if ( jasperPrint == null || jasperPrint.getPages() == null || jasperPrint.getPages().size() == 0 ) { pnlPage.setVisible(false); btnSave.setEnabled(false); btnPrint.setEnabled(false); btnActualSize.setEnabled(false); btnFitPage.setEnabled(false); btnFitWidth.setEnabled(false); btnZoomIn.setEnabled(false); btnZoomOut.setEnabled(false); cmbZoom.setEnabled(false); if (jasperPrint != null) { JOptionPane.showMessageDialog(this, getBundleString("no.pages")); } return; } pnlPage.setVisible(true); btnSave.setEnabled(true); btnPrint.setEnabled(true); btnActualSize.setEnabled(true); btnFitPage.setEnabled(true); btnFitWidth.setEnabled(true); btnZoomIn.setEnabled(zoom < MAX_ZOOM); btnZoomOut.setEnabled(zoom > MIN_ZOOM); cmbZoom.setEnabled(true); PrintPageFormat pageFormat = getPageFormat(); Dimension dim = new Dimension( (int)(pageFormat.getPageWidth() * realZoom) + 8, // 2 from border, 5 from shadow and 1 extra pixel for image (int)(pageFormat.getPageHeight() * realZoom) + 8 ); pnlPage.setMaximumSize(dim); pnlPage.setMinimumSize(dim); pnlPage.setPreferredSize(dim); long maxImageSize = JRPropertiesUtil.getInstance(jasperReportsContext).getLongProperty(VIEWER_RENDER_BUFFER_MAX_SIZE); boolean renderImage; if (maxImageSize <= 0) { renderImage = false; } else { long imageSize = ((int) (pageFormat.getPageWidth() * realZoom) + 1) * ((int) (pageFormat.getPageHeight() * realZoom) + 1); renderImage = imageSize <= maxImageSize; } ((PageRenderer)lblPage).setRenderImage(renderImage); if (renderImage) { setPageImage(); } pnlLinks.removeAll(); linksMap = new HashMap<JPanel,JRPrintHyperlink>(); createHyperlinks(); if (!renderImage) { lblPage.setIcon(null); pnlMain.validate(); pnlMain.repaint(); } }
Example #17
Source File: JRViewer.java From nordpos with GNU General Public License v3.0 | 4 votes |
/** */ private PrintPageFormat getPageFormat() { return jasperPrint.getPageFormat(pageIndex); }
Example #18
Source File: DocxDocumentHelper.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ public void exportSection(PrintPageFormat pageFormat, JRGridLayout pageGridLayout, boolean lastPage) { if (!lastPage) { write(" <w:p>\n"); write(" <w:pPr>\n"); } write(" <w:sectPr>\n"); write(" <w:pgSz w:w=\"" + LengthUtil.twip(pageFormat.getPageWidth()) + "\" w:h=\"" + LengthUtil.twip(pageFormat.getPageHeight()) + "\""); write(" w:orient=\"" + (pageFormat.getOrientation() == OrientationEnum.LANDSCAPE ? "landscape" : "portrait") + "\""); if(OoxmlUtils.getSuitablePaperSize(pageFormat) == PaperSizeEnum.UNDEFINED) { // unique identifier for the paper size write(" w:code=\""+ (1000 + pageFormat.getPageWidth() + pageFormat.getPageHeight()) +"\""); } write("/>\n"); CutsInfo xCuts = pageGridLayout.getXCuts(); Cut leftCut = xCuts.getCut(0); int gridLeftPadding = leftCut.isCutNotEmpty() ? 0 : pageGridLayout.getColumnWidth(0); int leftMargin = Math.min(gridLeftPadding, pageFormat.getLeftMargin()); Cut rightCut = xCuts.getCut(xCuts.size() - 2); int gridRightPadding = rightCut.isCutNotEmpty() ? 0 : pageGridLayout.getColumnWidth(xCuts.size() - 2); int rightMargin = Math.min(gridRightPadding, pageFormat.getRightMargin()); CutsInfo yCuts = pageGridLayout.getYCuts(); int topMargin = pageFormat.getTopMargin(); if (yCuts.size() > 1) { Cut topCut = yCuts.getCut(0); int gridTopPadding = topCut.isCutNotEmpty() ? 0 : pageGridLayout.getRowHeight(0); topMargin = Math.min(gridTopPadding, pageFormat.getTopMargin()); } //last y cut is from bottom element, not page height int gridBottomPadding = pageFormat.getPageHeight() - yCuts.getLastCutOffset(); int bottomMargin = LengthUtil.twip(Math.min(gridBottomPadding, pageFormat.getBottomMargin())) - DEFAULT_LINE_PITCH; bottomMargin = bottomMargin < 0 ? 0 : bottomMargin; write(" <w:pgMar w:top=\"" + LengthUtil.twip(topMargin) + "\" w:right=\"" + LengthUtil.twip(rightMargin) + "\" w:bottom=\"" + bottomMargin + "\" w:left=\"" + LengthUtil.twip(leftMargin) + "\" w:header=\"0\" w:footer=\"0\" w:gutter=\"0\" />\n"); // write(" <w:cols w:space=\"720\" />\n"); write(" <w:docGrid w:linePitch=\"" + DEFAULT_LINE_PITCH + "\" />\n"); write(" </w:sectPr>\n"); if (!lastPage) { write(" </w:pPr>\n"); write(" </w:p>\n"); } }
Example #19
Source File: JRViewerController.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
public PrintPageFormat getPageFormat() { return getJasperPrint().getPageFormat(getPageIndex()); }
Example #20
Source File: JRViewerPanel.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
protected void refreshPage() { if (!viewerContext.hasPages()) { pnlPage.setVisible(false); if (viewerContext.getJasperPrint() != null) { JOptionPane.showMessageDialog(this, viewerContext.getBundleString("no.pages")); } return; } pnlPage.setVisible(true); PrintPageFormat pageFormat = viewerContext.getPageFormat(); Dimension dim = new Dimension( (int)(pageFormat.getPageWidth() * realZoom) + 8, // 2 from border, 5 from shadow and 1 extra pixel for image (int)(pageFormat.getPageHeight() * realZoom) + 8 ); pnlPage.setMaximumSize(dim); pnlPage.setMinimumSize(dim); pnlPage.setPreferredSize(dim); long maxImageSize = JRPropertiesUtil.getInstance(viewerContext.getJasperReportsContext()).getLongProperty(JRViewer.VIEWER_RENDER_BUFFER_MAX_SIZE); boolean renderImage; if (maxImageSize <= 0) { renderImage = false; } else { long imageSize = ((int) (pageFormat.getPageWidth() * realZoom) + 1) * ((int) (pageFormat.getPageHeight() * realZoom) + 1); renderImage = imageSize <= maxImageSize; } lblPage.setRenderImage(renderImage); if (renderImage) { setPageImage(); } pnlLinks.removeAll(); linksMap = new HashMap<JPanel, JRPrintHyperlink>(); createHyperlinks(); if (!renderImage) { lblPage.setIcon(null); validate(); repaint(); } }
Example #21
Source File: JRViewerPanel.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
protected void drawPageError(Graphics grx) { PrintPageFormat pageFormat = viewerContext.getPageFormat(); grx.setColor(Color.white); grx.fillRect(0, 0, pageFormat.getPageWidth() + 1, pageFormat.getPageHeight() + 1); }
Example #22
Source File: JRGraphics2DExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ public void exportReportToGraphics2D(Graphics2D grx) throws JRException { grx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); //grx.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); grx.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); grx.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC); setCurrentExporterInputItem(exporterInput.getItems().get(0)); ReportExportConfiguration configuration = getCurrentItemConfiguration(); AffineTransform atrans = new AffineTransform(); atrans.translate( configuration.getOffsetX() == null ? 0 : configuration.getOffsetX(), configuration.getOffsetY() == null ? 0 : configuration.getOffsetY() ); float zoom = getZoom(); atrans.scale(zoom, zoom); grx.transform(atrans); List<JRPrintPage> pages = jasperPrint.getPages(); if (pages != null) { PageRange pageRange = getPageRange(); int startPageIndex = (pageRange == null || pageRange.getStartPageIndex() == null) ? 0 : pageRange.getStartPageIndex(); Shape oldClipShape = grx.getClip(); PrintPageFormat pageFormat = jasperPrint.getPageFormat(startPageIndex); grx.clip(new Rectangle(0, 0, pageFormat.getPageWidth(), pageFormat.getPageHeight())); try { exportPage(grx, startPageIndex); } finally { grx.setClip(oldClipShape); } } }
Example #23
Source File: JRPdfExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected PrintPageFormat getCurrentPageFormat() { return pageFormat; }
Example #24
Source File: JROdtExporter.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
/** * */ protected void exportReportToOasisZip(OutputStream os) throws JRException, IOException { OasisZip oasisZip = new OdtZip(); ExportZipEntry tempBodyEntry = new FileBufferedZipEntry(null); ExportZipEntry tempStyleEntry = new FileBufferedZipEntry(null); tempBodyWriter = new WriterHelper(jasperReportsContext, tempBodyEntry.getWriter()); tempStyleWriter = new WriterHelper(jasperReportsContext, tempStyleEntry.getWriter()); documentBuilder = new OdtDocumentBuilder(oasisZip); styleCache = new StyleCache(jasperReportsContext, tempStyleWriter, getExporterKey()); WriterHelper stylesWriter = new WriterHelper(jasperReportsContext, oasisZip.getStylesEntry().getWriter()); List<ExporterInputItem> items = exporterInput.getItems(); StyleBuilder styleBuilder = new StyleBuilder(stylesWriter); styleBuilder.buildBeforeAutomaticStyles(jasperPrint); pageFormatIndex = -1; for(reportIndex = 0; reportIndex < items.size(); reportIndex++) { ExporterInputItem item = items.get(reportIndex); rowStyles.clear(); columnStyles.clear(); setCurrentExporterInputItem(item); List<JRPrintPage> pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) { PageRange pageRange = getPageRange(); int startPageIndex = (pageRange == null || pageRange.getStartPageIndex() == null) ? 0 : pageRange.getStartPageIndex(); int endPageIndex = (pageRange == null || pageRange.getEndPageIndex() == null) ? (pages.size() - 1) : pageRange.getEndPageIndex(); PrintPageFormat oldPageFormat = null; JRPrintPage page = null; for(pageIndex = startPageIndex; pageIndex <= endPageIndex; pageIndex++) { if (Thread.interrupted()) { throw new ExportInterruptedException(); } PrintPageFormat pageFormat = jasperPrint.getPageFormat(pageIndex); if (oldPageFormat != pageFormat) { styleBuilder.buildPageLayout(++pageFormatIndex, pageFormat); oldPageFormat = pageFormat; } page = pages.get(pageIndex); exportPage(page); } } } styleBuilder.buildMasterPages(pageFormatIndex); stylesWriter.flush(); tempBodyWriter.flush(); tempStyleWriter.flush(); stylesWriter.close(); tempBodyWriter.close(); tempStyleWriter.close(); /* */ ContentBuilder contentBuilder = new ContentBuilder( oasisZip.getContentEntry(), tempStyleEntry, tempBodyEntry, styleCache.getFontFaces(), OasisZip.MIME_TYPE_ODT ); contentBuilder.build(); tempStyleEntry.dispose(); tempBodyEntry.dispose(); oasisZip.zipEntries(os); oasisZip.dispose(); }
Example #25
Source File: StandardPrintParts.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
@Override public PrintPageFormat getPageFormat(int pageIndex) { Map.Entry<Integer, PrintPart> partEntry = parts.floorEntry(pageIndex); return partEntry == null ? null : partEntry.getValue().getPageFormat(); }