public static void mainx(String[] args) { try (FileOutputStream arrayOutputStream = new FileOutputStream("D://qwe.pdf")) { Map<String, Object> parameters = new HashMap<>(); JRProperties.setProperty("net.sf.jasperreports.query.executer.factory.MongoDbQuery", "com.jaspersoft.mongodb.query.MongoDbQueryExecuterFactory"); MongoDbConnection connection = new MongoDbConnection("mongodb://localhost:27017/demodb", null, null); System.out.println("oooooooooo" + connection); JasperPrint jasperPrint = JasperFillManager.fillReport("D:\\_OITH_OUTPUT\\oith_ws_web\\trunk\\src\\main\\webapp\\reports\\oith.jasper", parameters, connection); System.out.println("kkkkkkwwwwwwwwwwwwwwww: " + jasperPrint.toString()); JasperExportManager.exportReportToPdfStream(jasperPrint, arrayOutputStream); } catch (Exception e) { System.out.println("errrr:" + e); } System.out.println("done"); }
private String getExtension() { if (JRProperties.getProperty("org.opennms.rrd.fileExtension") != null) { return JRProperties.getProperty("org.opennms.rrd.fileExtension"); } else if (System.getProperty("org.opennms.rrd.fileExtension") != null) { return System.getProperty("org.opennms.rrd.fileExtension"); } else { if (System.getProperty("org.opennms.rrd.strategyClass") != null) { return System.getProperty("org.opennms.rrd.strategyClass", "UnknownStrategy").endsWith("JRobinRrdStrategy") ? ".jrb" : ".rrd"; } return ".jrb"; } }
private String getRrdBinary() { if(System.getProperty("rrd.binary") != null) { return System.getProperty("rrd.binary"); } else if(JRProperties.getProperty("rrd.binary") != null) { return JRProperties.getProperty("rrd.binary"); } else { return null; } }
private String getExtension() { if(JRProperties.getProperty("org.opennms.rrd.fileExtension") != null) { return JRProperties.getProperty("org.opennms.rrd.fileExtension"); }else if(System.getProperty("org.opennms.rrd.fileExtension") != null) { return System.getProperty("org.opennms.rrd.fileExtension"); }else { if(System.getProperty("org.opennms.rrd.strategyClass") != null) { return System.getProperty("org.opennms.rrd.strategyClass", "UnknownStrategy").endsWith("JRobinRrdStrategy") ? ".jrb" : ".rrd"; } return ".jrb"; } }
/** */ 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); Dimension dim = new Dimension( (int)(jasperPrint.getPageWidth() * realZoom) + 8, // 2 from border, 5 from shadow and 1 extra pixel for image (int)(jasperPrint.getPageHeight() * realZoom) + 8 ); pnlPage.setMaximumSize(dim); pnlPage.setMinimumSize(dim); pnlPage.setPreferredSize(dim); long maxImageSize = JRProperties.getLongProperty(VIEWER_RENDER_BUFFER_MAX_SIZE); boolean renderImage; if (maxImageSize <= 0) { renderImage = false; } else { long imageSize = JRPrinterAWT.getImageSize(jasperPrint, realZoom); renderImage = imageSize <= maxImageSize; } lblPage.setRenderImage(renderImage); if (renderImage) { setPageImage(); } pnlLinks.removeAll(); linksMap = new HashMap(); createHyperlinks(); if (!renderImage) { lblPage.setIcon(null); pnlMain.validate(); pnlMain.repaint(); } }
/** */ protected void refreshPage() { if ( jasperPrint == null || jasperPrint.getPages() == null || jasperPrint.getPages().isEmpty() ) { 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); Dimension dim = new Dimension( (int)(jasperPrint.getPageWidth() * realZoom) + 8, // 2 from border, 5 from shadow and 1 extra pixel for image (int)(jasperPrint.getPageHeight() * realZoom) + 8 ); pnlPage.setMaximumSize(dim); pnlPage.setMinimumSize(dim); pnlPage.setPreferredSize(dim); long maxImageSize = JRProperties.getLongProperty(VIEWER_RENDER_BUFFER_MAX_SIZE); boolean renderImage; if (maxImageSize <= 0) { renderImage = false; } else { long imageSize = JRPrinterAWT.getImageSize(jasperPrint, realZoom); renderImage = imageSize <= maxImageSize; } lblPage.setRenderImage(renderImage); if (renderImage) { setPageImage(); } pnlLinks.removeAll(); linksMap = new HashMap(); createHyperlinks(); if (!renderImage) { lblPage.setIcon(null); pnlMain.validate(); pnlMain.repaint(); } }
/** * Create the default property map for a wide range of object * @param type the type of the element for which the properties are requested * @return the default properties of the requested element */ @SuppressWarnings("deprecation") private static HashMap<String, Object> initializeType(Object type){ HashMap<String, Object> result = new HashMap<String, Object>(); result.put(JRDesignStyle.PROPERTY_FONT_NAME, JRProperties.getProperty(JRFont.DEFAULT_FONT_NAME)); result.put(JRBaseLineBox.PROPERTY_PADDING, INTEGER_ZERO); result.put(JRBaseLineBox.PROPERTY_TOP_PADDING, INTEGER_ZERO); result.put(JRBaseLineBox.PROPERTY_RIGHT_PADDING, INTEGER_ZERO); result.put(JRDesignStyle.PROPERTY_PDF_FONT_NAME, JRProperties.getProperty(JRFont.DEFAULT_PDF_FONT_NAME)); result.put(JRDesignStyle.PROPERTY_PDF_ENCODING,JRProperties.getProperty(JRFont.DEFAULT_PDF_ENCODING)); result.put(JRDesignStyle.PROPERTY_PATTERN, null); result.put(JRDesignStyle.PROPERTY_MARKUP,JRCommonText.MARKUP_NONE); result.put(JRBasePen.PROPERTY_LINE_STYLE, LineStyleEnum.SOLID); if (type instanceof JRStyle){ result.put(JRDesignStyle.PROPERTY_FONT_SIZE, null); result.put(JRDesignStyle.PROPERTY_BOLD, null); result.put(JRDesignStyle.PROPERTY_ITALIC, null); result.put(JRDesignStyle.PROPERTY_UNDERLINE, null); result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, null); result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED,null); result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL,null); result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT,null); result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT,null); result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE,null); result.put(JRDesignStyle.PROPERTY_ROTATION,null); result.put(JRDesignStyle.PROPERTY_RADIUS,null); result.put(JRBasePen.PROPERTY_LINE_WIDTH, null); result.put(JRBasePen.PROPERTY_LINE_COLOR, null); result.put(JRDesignStyle.PROPERTY_BACKCOLOR, null); result.put(JRDesignStyle.PROPERTY_FORECOLOR, null); result.put(JRDesignStyle.PROPERTY_FILL, null); result.put(JRDesignStyle.PROPERTY_MODE, null); } else { result.put(JRDesignStyle.PROPERTY_FONT_SIZE, JRProperties.getIntegerProperty(JRFont.DEFAULT_FONT_SIZE)); result.put(JRDesignStyle.PROPERTY_BOLD, false); result.put(JRDesignStyle.PROPERTY_ITALIC, false); result.put(JRDesignStyle.PROPERTY_UNDERLINE, false); result.put(JRDesignStyle.PROPERTY_STRIKE_THROUGH, false); result.put(JRDesignStyle.PROPERTY_PDF_EMBEDDED,JRProperties.getBooleanProperty(JRFont.DEFAULT_PDF_EMBEDDED)); result.put(JRDesignStyle.PROPERTY_BLANK_WHEN_NULL,false); result.put(JRDesignStyle.PROPERTY_VERTICAL_ALIGNMENT,VerticalAlignEnum.TOP); result.put(JRDesignStyle.PROPERTY_HORIZONTAL_ALIGNMENT,HorizontalAlignEnum.LEFT); result.put(JRDesignStyle.PROPERTY_SCALE_IMAGE,ScaleImageEnum.RETAIN_SHAPE); result.put(JRDesignStyle.PROPERTY_ROTATION,RotationEnum.NONE); result.put(JRDesignStyle.PROPERTY_RADIUS,INTEGER_ZERO); result.put(JRBasePen.PROPERTY_LINE_WIDTH,JRPen.LINE_WIDTH_0); result.put(JRBasePen.PROPERTY_LINE_COLOR, Color.black); result.put(MGraphicElementLinePen.LINE_PEN, createBaseLinePen(type)); result.put(MGraphicElementLineBox.LINE_BOX, createBaseLineBox(type)); result.put(JRDesignStyle.PROPERTY_BACKCOLOR, Color.white); result.put(JRDesignStyle.PROPERTY_FORECOLOR, Color.black); result.put(JRDesignStyle.PROPERTY_FILL, FillEnum.SOLID); ModeEnum opaqueValue = ModeEnum.getByValue(ModeEnum.OPAQUE.getValue()); ModeEnum transparentValue = ModeEnum.getByValue(ModeEnum.TRANSPARENT.getValue()); if (type instanceof JRDesignTextElement){ result.put(JRDesignStyle.PROPERTY_MODE, transparentValue); } else if (type instanceof JRTemplateElement){ result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue); } else if (type instanceof JRBaseElement) { result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue); } else if (type instanceof JRBasePrintElement) { result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue); } else if (type instanceof JRFillElement){ result.put(JRDesignStyle.PROPERTY_MODE, opaqueValue); } else { result.put(JRDesignStyle.PROPERTY_MODE, transparentValue); } } return result; }
public boolean isStoreByGroup() { return JRProperties.getBooleanProperty("org.opennms.rrd.storeByGroup") || Boolean.getBoolean("org.opennms.rrd.storeByGroup"); }
public boolean isStoreByForeignSource() { return JRProperties.getBooleanProperty("org.opennms.rrd.storeByForeignSource") || Boolean.getBoolean("org.opennms.rrd.storeByForeignSource"); }