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; } }
List pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) pageWidth = jasperPrint.getPageWidth() / characterWidth; if (characterHeight > 0) pageHeight = jasperPrint.getPageHeight() / characterHeight;
JasperPrint jasperPrint = new JasperPrint(); jasperPrint.setName(atts.getValue(JRXmlConstants.ATTRIBUTE_name)); jasperPrint.setPageWidth(Integer.parseInt(pageWidth)); if (pageHeight != null && pageHeight.length() > 0) jasperPrint.setPageHeight(Integer.parseInt(pageHeight)); if (orientation != null) jasperPrint.setOrientation(orientation.byteValue()); if (formatFactoryClass != null) jasperPrint.setFormatFactoryClass(formatFactoryClass); if (locale != null) jasperPrint.setLocaleCode(locale); if (timezone != null) jasperPrint.setTimeZoneId(timezone);
/** * */ 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"); }
setJasperPrint((JasperPrint)jasperPrintList.get(reportIndex)); List pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0){ if (isModeBatch) writer.write(String.valueOf(twip(jasperPrint.getPageWidth()))); writer.write("\\paperh"); writer.write(String.valueOf(twip(jasperPrint.getPageHeight()))); if (jasperPrint.getOrientation() == JRReport.ORIENTATION_LANDSCAPE) { writer.write("\\lndscpsxn");
xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_name, jasperPrint.getName()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageWidth, jasperPrint.getPageWidth()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_pageHeight, jasperPrint.getPageHeight()); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_orientation, jasperPrint.getOrientation(), JRXmlConstants.getOrientationMap(), JRReport.ORIENTATION_PORTRAIT); xmlWriter.addAttribute(JRXmlConstants.ATTRIBUTE_formatFactoryClass, jasperPrint.getFormatFactoryClass()); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_locale, jasperPrint.getLocaleCode()); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_timezone, jasperPrint.getTimeZoneId()); xmlWriter.addEncodedAttribute(JRXmlConstants.ATTRIBUTE_value, jasperPrint.getPages() == null ? null : String.valueOf(jasperPrint.getPages().size())); xmlWriter.closeElement(); JROrigin[] origins = jasperPrint.getOrigins(); if (origins != null && origins.length > 0) JRReportFont[] fonts = jasperPrint.getFonts(); if (fonts != null && fonts.length > 0) JRStyle[] styles = jasperPrint.getStyles(); if (styles != null && styles.length > 0) List pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0)
/** * Transforms y coordinates from pixel space to character space. */ protected int calculateYCoord(int y) { return (int) (((long) pageHeight * y) / jasperPrint.getPageHeight()); }
jasperPrint = new JasperPrint(); jasperPrint.setDefaultFont(report.getDefaultFont()); jasperPrint.setFormatFactoryClass(report.getFormatFactoryClass()); jasperPrint.setName(report.getName()); jasperPrint.setOrientation(report.getOrientation()); jasperPrint.setPageWidth(report.getPageWidth()); jasperPrint.setPageHeight(report.getPageHeight()); addBand(report.getNoData()); jasperPrint.setPageHeight(offsetY + report.getBottomMargin()); addVerticalGridLine(report.getLeftMargin(), 0, jasperPrint.getPageHeight()); addVerticalGridLine(pageWidth - report.getRightMargin(), 0, jasperPrint.getPageHeight()); jasperPrint.addPage(page);
defaultFont = new JRBasePrintText(jasperPrint.getDefaultStyleProvider()); List pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) tempBodyWriter.write("<Worksheet ss:Name=\""+getSheetName(jasperPrint.getName())+"\">\n"); JRGridLayout.calculateXCuts( nature, pages, startPageIndex, endPageIndex, jasperPrint.getPageWidth(), globalOffsetX );
for (JRPrintPage page : jasperPrint.getPages()) { for (JRPrintElement element : page.getElements()) { addTocHeading(headings, headingList, element, pageNumber); int i = 0; i < tocJasperPrint.getPages().size(); i++) { JRPrintPage page = tocJasperPrint.getPages().get(i); switch (tableOfContentsPosition) { case TOP: jasperPrint.addPage(i, page); break; case BOTTOM: jasperPrint.addPage(page); break; default: for (JRStyle style : tocJasperPrint.getStyles()) { jasperPrint.addStyle(style);
/** * Transforms x coordinates from pixel space to character space. */ protected int calculateXCoord(int x) { return pageWidth * x / jasperPrint.getPageWidth(); }
Map anchorIndexes = jasperPrint.getAnchorIndexes(); JRPrintAnchorIndex anchorIndex = (JRPrintAnchorIndex)anchorIndexes.get(hyperlink.getHyperlinkAnchor()); if (anchorIndex.getPageIndex() != pageIndex) if (page >= 1 && page <= jasperPrint.getPages().size() && page != pageIndex + 1)
setJasperPrint((JasperPrint)jasperPrintList.get(reportIndex)); getFontIndex(new JRBasePrintText(jasperPrint.getDefaultStyleProvider())); List pages = jasperPrint.getPages(); if (pages != null && pages.size() > 0) { if (isModeBatch) {
jasperPrint.addStyle(style); jasperPrint.setDefaultStyle(printDefault);
/** * Adds a new style to the report styles. */ public synchronized void addStyle(JRStyle style) throws JRException { addStyle(style, false); }
private JasperPrint runAndRender(Report report) throws Exception, JRException { JasperPrint jasperPrint = new JasperPrint(); JasperReport jasperReport = JasperCompileManager.compileReport( System.getProperty("opennms.home") + File.separator + "etc" + File.separator + "report-templates" + File.separator + report.getReportTemplate() ); if(report.getReportEngine().equals("jdbc")){ Connection connection = DataSourceFactory.getInstance().getConnection(); jasperPrint = JasperFillManager.fillReport(jasperReport, paramListToMap(report.getParameters()), connection ); connection.close(); } else if(report.getReportEngine().equals("opennms")){ LOG.error("Sorry the OpenNMS Data source engine is not yet available"); jasperPrint = null; } else{ LOG.error("Unknown report engine: {} ", report.getReportEngine()); jasperPrint = null; } return jasperPrint; }
JRStyle[] styles = jasperPrint.getStyles(); if (styles != null)
firstPageIndex < 0 || firstPageIndex > lastPageIndex || lastPageIndex >= jasperPrint.getPages().size() firstPageIndex + " - " + lastPageIndex + " of " + jasperPrint.getPages().size() ); printJob.setJobName("JasperReports - " + jasperPrint.getName()); switch (jasperPrint.getOrientation()) paper.setSize(jasperPrint.getPageHeight(), jasperPrint.getPageWidth()); paper.setImageableArea( 0, 0, jasperPrint.getPageHeight(), jasperPrint.getPageWidth() ); break; paper.setSize(jasperPrint.getPageWidth(), jasperPrint.getPageHeight()); paper.setImageableArea( 0, 0, jasperPrint.getPageWidth(), jasperPrint.getPageHeight() );