Java 类net.sf.jasperreports.engine.JasperExportManager 实例源码

项目:logistimo-web-service    文件:JasperClient.java   
public PDFResponseModel generatePDF(String fileName, String template, String bucketName,
    Collection<?> items, Map<String, Object> parameters)
    throws ClassNotFoundException, JRException, IOException {

  JasperPrint jasperPrint;
  InputStream inputStream = null;

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(items);

  try {
    inputStream = storageUtil.getInputStream(bucketName, template);
    jasperPrint = JasperFillManager.fillReport(JasperCompileManager.compileReport(
        inputStream), parameters, beanColDataSource);
    byte[] pdfBytes = JasperExportManager.exportReportToPdf(jasperPrint);
    return new PDFResponseModel(fileName, pdfBytes);
  } catch (ClassNotFoundException | JRException | IOException e) {
    xLogger.severe("Failed to generate PDF for file name - ", fileName, e);
    throw e;
  } finally {
    if (inputStream != null) {
      inputStream.close();
    }
  }
}
项目:logistimo-web-service    文件:GenerateInvoiceTest.java   
@Test
public void testInvoice(){
  List<InvoiceItem> invoiceItems = new ArrayList<>();

  int count = 1;
  for (IDemandItem demandItem : getDemandItems()) {
    InvoiceItem invoiceItem = new InvoiceItem();
    invoiceItem.setItem(demandItem.getMaterialId().toString());
    invoiceItem.setQuantity(demandItem.getQuantity().toString());
    invoiceItem.setRecommended(demandItem.getRecommendedOrderQuantity().toString());
    invoiceItem.setRemarks("Blah");
      invoiceItem.setBatchId("AB/1234/56"+count);
      invoiceItem.setExpiry("11/03/2020");
      invoiceItem.setManufacturer("Serum");
      invoiceItem.setBatchQuantity(BigDecimal.TEN.toPlainString());
    invoiceItem.setSno(String.valueOf(count++));
    invoiceItems.add(invoiceItem);
  }

  JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(invoiceItems);

  try {

    Map<String, Object> hm = new HashMap<>();
    JasperPrint jasperPrint = JasperFillManager.fillReport(
        JasperCompileManager
            .compileReport(Thread.currentThread().getContextClassLoader().getResourceAsStream(
                "test_logistimo_invoice.jrxml")), hm, beanColDataSource);

    JasperExportManager.exportReportToPdfFile(jasperPrint, "/tmp/logistimo_invoice.pdf");


  } catch (Exception e) {
    e.printStackTrace();
  }


}
项目:openbravo-brazil    文件:ReportingUtils.java   
/**
 * Saves a pre-compiled report into a file.
 * 
 * @param jasperPrint
 *          JasperPrint object which contains a compiled report.
 * @param expType
 *          The desired output type of the report.
 * @param exportParameters
 *          Export parameters than can be added to configure the resulting report.
 * @param target
 *          The file used to return the report.
 * @throws JRException
 *           In case there is any error saving the report an exception is thrown with the error
 *           message.
 */
public static void saveReport(JasperPrint jasperPrint, ExportType expType,
    Map<Object, Object> exportParameters, File target) throws JRException {
  switch (expType) {
  case CSV:
    saveCsvReportToFile(jasperPrint, target);
    break;
  case HTML:
    if (log.isDebugEnabled())
      log.debug("JR: Print HTML");
    saveHTMLReportToFile(jasperPrint, exportParameters, target);
    break;
  case PDF:
    JasperExportManager.exportReportToPdfFile(jasperPrint, target.getAbsolutePath());
    break;
  case TXT:
    saveTxtReportToFile(jasperPrint, target);
    break;
  case XLS:
    saveExcelReportToFile(jasperPrint, exportParameters, target);
    break;
  case XML:
    JasperExportManager.exportReportToXmlFile(jasperPrint, target.getAbsolutePath(), true);
    break;
  }
}
项目:Java-Danfe    文件:DanfeNfe.java   
private static void gerarDanfe(String url, List<String> emit, List<String> dest, List<String> nota, JRDataSource itens, String qrcode){
    try {
        // Teste
        //String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
        String output = "danfe.pdf"; 
        map.put("emit", emit);
        map.put("dest", dest);
        map.put("nota", nota);
        map.put("qrcode", qrcode);
        // Relatório compilado
        JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
        //InputStream jasperStream = getClass().getResourceAsStream("/Foo.jasper");
        //JasperReport report = (JasperReport) JRLoader.loadObject(jasperStream);
        // Relatório nao compilado
        //JasperReport report = JasperCompileManager.compileReport(jrxml);
        JasperPrint print = JasperFillManager.fillReport(report, map, itens);
        JasperExportManager.exportReportToPdfFile(print, output);
    } catch (JRException e) {
        System.out.println("erro: "+e.getMessage());
    }
}
项目:jasperreports    文件:ExcelDataAdapterApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    File[] files = getFiles(new File("build/reports"), "jrprint");
    for(int i = 0; i < files.length; i++)
    {
        File reportFile = files[i];
        long start = System.currentTimeMillis();
        String fileName = reportFile.getAbsolutePath();
        JasperExportManager.exportReportToPdfFile(
            fileName, 
            fileName.substring(0, fileName.indexOf(".jrprint")) + ".pdf"
            );
        System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
    }
}
项目:Java-Danfe    文件:DanfeNfe.java   
private static void gerarDanfeNfse(String url, List<String> emit, List<String> dest, List<String> ser, List<String> nota, String xml, String logo) {
    try {
        // Teste
        //String compilado = System.getProperty("user.dir") + "/danfe_nfce_80.jasper";;
        String output = "danfe.pdf"; 
        map.put("emit", emit);
        map.put("dest", dest);
        map.put("ser", ser);
        map.put("nota", nota);
        map.put("logo", logo);
        // brasao
        String brasao = Paths.get(System.getProperty("user.dir"), "danfe","brasao.png").toAbsolutePath().toString();
        map.put("brasao", brasao);
        // JrDataSource
        JRDataSource jr = new JRXmlDataSource(xml);
        // Relatório compilado
        JasperReport report = (JasperReport) JRLoader.loadObjectFromFile(url);
        JasperPrint print = JasperFillManager.fillReport(report, map, jr);
        JasperExportManager.exportReportToPdfFile(print, output);
    } catch (JRException e) {
        System.out.println("erro: "+e.getMessage());
    }
}
项目:jasperreports    文件:HttpDataAdapterApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    File[] files = getFiles(new File("build/reports"), "jrprint");
    for(int i = 0; i < files.length; i++)
    {
        File reportFile = files[i];
        long start = System.currentTimeMillis();
        String fileName = reportFile.getAbsolutePath();
        JasperExportManager.exportReportToPdfFile(
            fileName, 
            fileName.substring(0, fileName.indexOf(".jrprint")) + ".pdf"
            );
        System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
    }
}
项目:webpedidos    文件:EmissorRelatorioServlet.java   
@Override
public void emitir() throws JRException {
    try (InputStream relatorioArquivoStream = this.getClass().getResourceAsStream(relatorio.getArquivo().getCaminho())) {
        JasperPrint print = JasperFillManager.fillReport(relatorioArquivoStream, relatorio.getParametros(), connection);
        this.relatorioGerado = print.getPages().size() > 0;

        if(this.isRelatorioGerado()) {
            String attachment = String.format("attachment; filename=\"%s.pdf\"", relatorio.getArquivo().getNome());
            servletResponse.setHeader("Content-Disposition", attachment);
            JasperExportManager.exportReportToPdfStream(print, servletResponse.getOutputStream());      
        }
    } catch (IOException e) {
        throw new RelatorioNaoExisteException(relatorio, e);
    }
}
项目:jasperreports    文件:XChartApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/XChartReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:JasperApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/FirstJasper.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:LandscapeApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/LandscapeReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:JFreeChartApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/JFreeChartReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:UnicodeApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/UnicodeReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:JsonQLDataSourceApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    File[] files = getFiles(new File("build/reports"), "jrprint");
    for(int i = 0; i < files.length; i++)
    {
        File reportFile = files[i];
        long start = System.currentTimeMillis();
        JasperExportManager.exportReportToPdfFile(reportFile.getAbsolutePath());
        System.err.println("Report : " + reportFile + ". PDF export time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:UnicodeApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/UnicodeReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:BookApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/BookReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:BookApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/BookReport.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:TableOfContentsApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/TableOfContentsReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:XChartApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/XChartReport.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:ChartsApp.java   
/**
 *
 */
public void html() throws JRException
{
    File[] files = getFiles(new File("build/reports"), "jrprint");
    for(int i = 0; i < files.length; i++)
    {
        File reportFile = files[i];
        long start = System.currentTimeMillis();
        JasperExportManager.exportReportToHtmlFile(
            reportFile.getAbsolutePath()
            );
        System.err.println("Report : " + reportFile + ". HTML export time : " + (System.currentTimeMillis() - start));
    }
}
项目:jasperreports    文件:JsonDataSourceApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/JsonCustomersReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:IconLabelApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/IconLabelReport.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:JasperApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/FirstJasper.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:GenericElementApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/GenericElementReport.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:DateRangeApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/DateRangeReport.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:DataSourceApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/DataSourceReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:DateRangeApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/DateRangeReport.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:SpiderChartApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/SpiderChart.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:HtmlComponentApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/HtmlComponentReport.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:LandscapeApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/LandscapeReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:EjbqlApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/JRMDbReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:FontsApp.java   
/**
 *
 */
public void html() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToHtmlFile("build/reports/FontsReport.jrprint");
    System.err.println("HTML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:FormsApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/FormsReport.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:FormsApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/FormsReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:FormsApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/FormsReport.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:JasperApp.java   
/**
 *
 */
public void xmlEmbed() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/FirstJasper.jrprint", true);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:StyledTextApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/StyledTextReport.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:StyledTextApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/StyledTextReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:FunctionsApp.java   
/**
 *
 */
public void pdf() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToPdfFile("build/reports/FunctionsReport.jrprint");
    System.err.println("PDF creation time : " + (System.currentTimeMillis() - start));
}
项目:jasperreports    文件:NoReportApp.java   
/**
 *
 */
public void xml() throws JRException
{
    long start = System.currentTimeMillis();
    JasperExportManager.exportReportToXmlFile("build/reports/NoReport.jrprint", false);
    System.err.println("XML creation time : " + (System.currentTimeMillis() - start));
}