欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

iReport生成pdf打印的實(shí)例代碼

 更新時(shí)間:2017年11月30日 09:16:16   作者:淺安  
下面小編就為大家分享一篇iReport生成pdf打印的實(shí)例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧

先下載ireport版本 ,我下載的是 iReport-5.0.4  編輯模板  employees_identity_print_templet

@RequestMapping("printEmpPdf")
 @ResponseBody
 public Result printEmpPdf(HttpServletRequest request,HttpServletResponse response, Parameter parameter){
 Result result=Result.getInitializedResult();
 try{
  parameter = generateParameter(parameter, request);
  Map<String,Object> map= parameter.getParam();
  List<EmployeeVO> employeeVOList=employeeBiz.printPdfBarcode(map);

  // 報(bào)表數(shù)據(jù)源
  JRDataSource jrDataSource = new JRBeanCollectionDataSource(employeeVOList);
  //模板地址
  String jasperSource_adidas= CommonUtils.getAllMessage("jdbc","EMPLOYEES_IDENTITY_PRINT_PDF_TEMPLET")+"employees_identity_print_templet.jasper";
  File reportFile = new File(jasperSource_adidas);
  Map<String, Object> param_common=new HashMap<String, Object>();
  param_common.put("subReport",jasperSource_adidas);
  JasperPrint jasperPrint;
  jasperPrint = JasperFillManager.fillReport(reportFile.getPath(), param_common, jrDataSource);
  String fullPath = String.valueOf(System.currentTimeMillis()).concat("_員工列表.pdf"); //生成PDF文件保存地址
  String filePdfUrl= CommonUtils.getAllMessage("jdbc","IREPORT_FILE_URL");
  JRPdfExporter pdfExporter = new JRPdfExporter();
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  pdfExporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);
  pdfExporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);
  pdfExporter.exportReport();
  byte[] bytes = baos.toByteArray();
  File file=new File(filePdfUrl+fullPath);
  WebUtil.writeByteArrayToFile(file,bytes);
  result.baseSucResult(fullPath);
 }catch (Exception e){
  result.baseFailResult("EmployeeController printEmpPdf error",parameter);
  logger.error("EmployeeController printEmpPdf error",e);
 }
 return result;
 }

 這是需要的maven 包

<dependency>
 <groupId>net.sf.jasperreports</groupId>
 <artifactId>jasperreports</artifactId>
 <version>5.6.0</version>
</dependency>
<dependency>
 <groupId>org.codehaus.groovy</groupId>
 <artifactId>groovy-all</artifactId>
 <version>2.2.2</version>
</dependency>

<!-- iReport PDF中文支持 -->
<dependency>
 <groupId>com.lowagie</groupId>
 <artifactId>itextasian</artifactId>
 <version>2.1.7.js2</version>
</dependency>
<dependency>
 <groupId>com.lowagie</groupId>
 <artifactId>itext</artifactId>
 <version>2.1.7.js2</version>
</dependency>
<dependency>
 <groupId>net.sourceforge.barbecue</groupId>
 <artifactId>barbecue</artifactId>
 <version>1.5-beta1</version>
</dependency>

<dependency>
 <groupId>ireport</groupId>
 <artifactId>ireport-utils</artifactId>
 <version>2.0.1</version>
</dependency>

<dependency>
 <groupId>commons-collections</groupId>
 <artifactId>commons-collections</artifactId>
 <version>3.2</version>
</dependency>
<dependency>
 <groupId>commons-digester</groupId>
 <artifactId>commons-digester</artifactId>
 <version>1.8</version>
</dependency>

以上這篇iReport生成pdf打印的實(shí)例代碼就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • Elasticsearch學(xué)習(xí)之Terms?set?查詢(xún)

    Elasticsearch學(xué)習(xí)之Terms?set?查詢(xún)

    這篇文章主要為大家介紹了Elasticsearch學(xué)習(xí)Terms?set?查詢(xún)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-02-02
  • 解決找不到符號(hào) 符號(hào):變量 log問(wèn)題

    解決找不到符號(hào) 符號(hào):變量 log問(wèn)題

    這篇文章主要介紹了解決找不到符號(hào) 符號(hào): 變量 log問(wèn)題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Java關(guān)于桶排序的知識(shí)點(diǎn)總結(jié)

    Java關(guān)于桶排序的知識(shí)點(diǎn)總結(jié)

    這篇文章給大家總結(jié)了關(guān)于JAVA中J桶排序的相關(guān)知識(shí)點(diǎn)和用法分享,有興趣的讀者跟著學(xué)習(xí)下。
    2018-04-04
  • spring 自動(dòng)裝配和aop的使用

    spring 自動(dòng)裝配和aop的使用

    這篇文章主要介紹了spring 自動(dòng)裝配和aop的使用,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-07-07
  • MyBatis-Plus將字段修改為空值的解決方案

    MyBatis-Plus將字段修改為空值的解決方案

    這篇文章主要介紹了MyBatis-Plus將字段修改為空值的解決方案,本文給大家分享三種常用的解決方案,感興趣的朋友一起看看吧
    2023-12-12
  • 基于Java實(shí)現(xiàn)互聯(lián)網(wǎng)實(shí)時(shí)聊天系統(tǒng)(附源碼)

    基于Java實(shí)現(xiàn)互聯(lián)網(wǎng)實(shí)時(shí)聊天系統(tǒng)(附源碼)

    Netty?是一個(gè)利用?Java?的高級(jí)網(wǎng)絡(luò)的能力,隱藏其背后的復(fù)雜性而提供一個(gè)易于使用的?API?的客戶(hù)端/服務(wù)器框架。本文將利用它實(shí)現(xiàn)互聯(lián)網(wǎng)實(shí)時(shí)聊天系統(tǒng),感興趣的可以了解一下
    2022-09-09
  • 淺析SpringBoot多數(shù)據(jù)源實(shí)現(xiàn)方案

    淺析SpringBoot多數(shù)據(jù)源實(shí)現(xiàn)方案

    現(xiàn)在很多項(xiàng)目的開(kāi)發(fā)過(guò)程中,可能涉及到多個(gè)數(shù)據(jù)源,像讀寫(xiě)分離的場(chǎng)景,或者因?yàn)闃I(yè)務(wù)復(fù)雜,導(dǎo)致不同的業(yè)務(wù)部署在不同的數(shù)據(jù)庫(kù)上,那么這樣的場(chǎng)景,我們應(yīng)該如何在代碼中簡(jiǎn)潔方便的切換數(shù)據(jù)源呢,本文介紹SpringBoot多數(shù)據(jù)源實(shí)現(xiàn)方案,感興趣的朋友跟隨小編一起看看吧
    2024-02-02
  • Java 詳細(xì)講解分治算法如何實(shí)現(xiàn)歸并排序

    Java 詳細(xì)講解分治算法如何實(shí)現(xiàn)歸并排序

    分治算法的基本思想是將一個(gè)規(guī)模為N的問(wèn)題分解為K個(gè)規(guī)模較小的子問(wèn)題,這些子問(wèn)題相互獨(dú)立且與原問(wèn)題性質(zhì)相同。求出子問(wèn)題的解,就可得到原問(wèn)題的解,本篇文章我們就用分治算法來(lái)實(shí)現(xiàn)歸并排序
    2022-04-04
  • SpringBoot解析指定Yaml配置文件的實(shí)現(xiàn)過(guò)程

    SpringBoot解析指定Yaml配置文件的實(shí)現(xiàn)過(guò)程

    這篇文章主要介紹了SpringBoot解析指定Yaml配置文件,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-03
  • SpringBoot在自定義類(lèi)中調(diào)用service層等Spring其他層操作

    SpringBoot在自定義類(lèi)中調(diào)用service層等Spring其他層操作

    這篇文章主要介紹了SpringBoot在自定義類(lèi)中調(diào)用service層等Spring其他層操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-06-06

最新評(píng)論