/** * @deprecated Replaced by {@link JasperExportManager#exportReportToPdfFile(String)}. */ public static String printReportToPdfFile(String sourceFileName) throws JRException { return JasperExportManager.exportReportToPdfFile(sourceFileName); }
/** * @deprecated Replaced by {@link JasperExportManager#exportReportToPdfFile(String, String)}. */ public static void printReportToPdfFile( String sourceFileName, String destFileName ) throws JRException { JasperExportManager.exportReportToPdfFile(sourceFileName, destFileName); }
/** * @deprecated Replaced by {@link JasperExportManager#exportReportToPdfFile(String)}. */ public static String printReportToPdfFile(String sourceFileName) throws JRException { return JasperExportManager.exportReportToPdfFile(sourceFileName); }
/** * @deprecated Replaced by {@link JasperExportManager#exportReportToPdfFile(JasperPrint, String)}. */ public static void printReportToPdfFile( JasperPrint jasperPrint, String destFileName ) throws JRException { JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); }
/** * @deprecated Replaced by {@link JasperExportManager#exportReportToPdfFile(String, String)}. */ public static void printReportToPdfFile( String sourceFileName, String destFileName ) throws JRException { JasperExportManager.exportReportToPdfFile( sourceFileName, destFileName ); }
/** * @deprecated Replaced by {@link JasperExportManager#exportReportToPdfFile(JasperPrint, String)}. */ public static void printReportToPdfFile( JasperPrint jasperPrint, String destFileName ) throws JRException { JasperExportManager.exportReportToPdfFile( jasperPrint, destFileName ); }
/** * Export to PDF * * @return SpecificTemplateExporterBuilderService * @throws JRException JRException exception */ public SpecificTemplateExporterBuilderService toPDF() throws JRException { JasperExportManager.exportReportToPdfFile(this.report, getTemplatePath().replace(extensionPattern, "pdf")); return this; }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. */ public static void runReportToPdfFile( String sourceFileName, String destFileName, Map parameters, Connection conn ) throws JRException { /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, conn); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); }
private void exportPDF(String destinationFolder, String reportName, JasperPrint jasperPrint) throws JRException { JasperExportManager.exportReportToPdfFile(jasperPrint, destinationFolder + File.separatorChar + reportName + "." + EXPORT_FORMAT.PDF.toString().toLowerCase()); }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. */ public static void runReportToPdfFile( String sourceFileName, String destFileName, Map parameters, JRDataSource jrDataSource ) throws JRException { /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters, jrDataSource); /* */ JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); }
/** * Exports the generated report file specified by the first parameter into PDF format, * the result being placed in the second file parameter. * * @param sourceFileName source file containing the generated report * @param destFileName file name to place the PDF content into * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public static void exportReportToPdfFile( String sourceFileName, String destFileName ) throws JRException { JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFileName); exportReportToPdfFile(jasperPrint, destFileName); }
@Override public File generatePdf() { try { JasperPrint impressoraJasper = processaDadosJasper(); File arquivoPdfGeracao = File.createTempFile(fileName(), ".pdf"); JasperExportManager.exportReportToPdfFile(impressoraJasper, arquivoPdfGeracao.getAbsolutePath()); return arquivoPdfGeracao; } catch (Exception e) { e.printStackTrace(); } return null; }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. * * @param sourceFileName source file containing the compile report design * @param destFileName PDF destination file name * @param parameters report parameters map * @throws JRException * @see net.sf.jasperreports.engine.fill.JRFiller#fillReport(JasperReport, Map) */ public static void runReportToPdfFile( String sourceFileName, String destFileName, Map parameters ) throws JRException { /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(sourceFileName, parameters); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); }
/** * Exports the generated report file specified by the parameter into PDF format. * The resulting PDF file has the same name as the report object inside the source file, * plus the <code>*.pdf</code> extension and it is located in the same directory as the source file. * * @param sourceFileName source file containing the generated report * @return resulting PDF file name * @see net.sf.jasperreports.engine.export.JRPdfExporter */ public static String exportReportToPdfFile(String sourceFileName) throws JRException { File sourceFile = new File(sourceFileName); /* We need the report name. */ JasperPrint jasperPrint = (JasperPrint)JRLoader.loadObject(sourceFile); File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); String destFileName = destFile.toString(); exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
/** * 根据指定的参数和Bean Collection数据源导出PDF文件 * @param jasperFile jasper文件路径 * @param toFile 目标pdf文件的路径,可以指定或者为null * @param params 模板所需的参数 * @param dataSource 模板所需的数据源 * @param <T> 数据源泛型 * @return 返回导出的PDF文件的路径,需要注意绝对路径和相对路径 */ public static <T> String exportPdf(String jasperFile, String toFile, Map<String, Object> params, List<T> dataSource) { String pdfFile = null; try { String jasperPrintFile = getJasperPrintFile(jasperFile, params, dataSource); if (toFile != null) { pdfFile = toFile; JasperExportManager.exportReportToPdfFile(jasperPrintFile, pdfFile); } else { pdfFile = JasperExportManager.exportReportToPdfFile(jasperPrintFile); } } catch (JRException e) { logger.error(e.getMessage()); } return pdfFile; }
public StreamedContent exportPdf(String name) throws JRException, IOException { DynamicReport dynamicReport = dynamicReportBuilder.build(); File arquivoPdfGeracao = File.createTempFile(name, ".pdf"); String path = arquivoPdfGeracao.getPath().substring(0, arquivoPdfGeracao.getPath().indexOf(arquivoPdfGeracao.getName())); JRFileVirtualizer virtualizer = new JRFileVirtualizer(5, path); parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer); JRDataSource ds = new JRBeanCollectionDataSource(listData); JasperPrint jasperPrint = DynamicJasperHelper.generateJasperPrint(dynamicReport, new ClassicLayoutManager(), ds, parameters); InputStream pdfStream = new FileInputStream(arquivoPdfGeracao.getAbsolutePath()); JasperExportManager.exportReportToPdfFile(jasperPrint, arquivoPdfGeracao.getAbsolutePath()); return new DefaultStreamedContent(pdfStream, "application/pdf", name + ".pdf"); }
public static String geraArquivoPDF(List<?> lista, String nomeRelatorio, Map<String, Object> parametros) throws IOException, JRException { Map<String, Object> parametrosGeral = (Map<String, Object>) ((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getServletContext().getAttribute("parametrosRelatorio"); if (parametrosGeral != null) { Set<String> listaChave = parametrosGeral.keySet(); for (String chave : listaChave) { parametros.put(chave, parametrosGeral.get(chave)); } } String arquivo = getPath("relatorios") + nomeRelatorio + ".jasper"; InputStream relatorio; if (new File(arquivo).exists()) { relatorio = new FileInputStream(arquivo); } else { relatorio = JasperReportsUtils.class.getResourceAsStream("/relatorios/" + nomeRelatorio + ".jasper"); } if (relatorio == null) { throw new JRException("Não foi possivel localizar o relatorio " + nomeRelatorio + ".jasper"); } JasperPrint impressoraJasper = JasperFillManager.fillReport(relatorio, parametros, new JRBeanCollectionDataSource(lista)); File file = File.createTempFile(nomeRelatorio, ".pdf"); JasperExportManager.exportReportToPdfFile(impressoraJasper, file.getAbsolutePath()); relatorio.close(); return file.getAbsolutePath(); }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. */ public static String runReportToPdfFile( String sourceFileName, Map parameters, Connection conn ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, conn); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); String destFileName = destFile.toString(); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
/** * Fills a report and saves it directly into a PDF file. * The intermediate JasperPrint object is not saved on disk. */ public static String runReportToPdfFile( String sourceFileName, Map parameters, JRDataSource jrDataSource ) throws JRException { File sourceFile = new File(sourceFileName); /* */ JasperReport jasperReport = (JasperReport)JRLoader.loadObject(sourceFile); parameters = JasperFillManager.setFileResolver(sourceFile, parameters); /* */ JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters, jrDataSource); /* */ File destFile = new File(sourceFile.getParent(), jasperPrint.getName() + ".pdf"); String destFileName = destFile.toString(); JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); return destFileName; }
switch(Format.valueOf(report.getReportFormat())){ case pdf: JasperExportManager.exportReportToPdfFile(jasperPrint, destFileName); reportName = destFileName; break;