1. 程式人生 > >springMVC中itext生成PDF,根本上解決中文亂碼以及不顯示問題

springMVC中itext生成PDF,根本上解決中文亂碼以及不顯示問題

itext生成PDF,根本上解決中文不顯示問題

1、建立maven工程,在pom檔案中引入下面的jar包

<span style="font-size:12px;"><dependency>
			<groupId>org.xhtmlrenderer</groupId>
			<artifactId>core-renderer</artifactId>
			<version>R8</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.itextpdf/itext-asian -->
	 	 <dependency>
			<groupId>com.itextpdf</groupId>
			<artifactId>itext-asian</artifactId>
			<version>5.2.0</version>
		</dependency>  
		<dependency>
			<groupId>com.itextpdf</groupId>
			<artifactId>itextpdf</artifactId>
			<version>5.5.1</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.itextpdf.tool/xmlworker -->
		<dependency>
			<groupId>com.itextpdf.tool</groupId>
			<artifactId>xmlworker</artifactId>
			<version>5.5.7</version>
		</dependency></span>

2、spring中新建一個生成PDF的controller

	<span style="font-size:12px;">/**
	 * @throws Exception 
	 * @Definition : 匯出PDF格式的簡歷 
	 * @Author: xiachao
	 * @Time: 2016年9月19日
	 */
    @RequestMapping("exportPdf")  
    public ResponseEntity<byte[]> exportPdf(HttpServletRequest request, HttpServletResponse response) throws Exception{   
    	Account a = getCurAccount(request);
    	Integer accountId = a.getAccId();
    	Map resultMap = accountService.findAllProfileAndResumeForExport(accountId);
    	File oFile = ExportPdfUtil.getPdf(a, resultMap);
    	HttpHeaders headers = new HttpHeaders();      
        String fileName = null;  
        fileName = new String((a.getRealName()+"簡歷-"+"迷你校.pdf").getBytes("utf-8"),"iso-8859-1");//解決中文亂碼
        headers.setContentDispositionFormData("attachment", fileName);     
        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);  
	  return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(oFile),headers, HttpStatus.OK);  
    }</span>

3、在工程的common包下新建一個生成PDF的工具類,即上面controller中的ExportPDFUtility類

<span style="font-size:12px;"> /**
	  * @Definition 另一種方式匯出簡歷PDF   
	  * @author xiachao
	  * @Data 2016-9-28
	  * @throws Exception 
	  */
	 public static File getPdf(Account account,Map map) throws Exception{
		    PdfPCell cell1 =null;
		    String fileName = "test.pdf";
		    File outFile = new File(Constant.pdfExportPath + File.separator + fileName);
	        if (! outFile.exists()) {
				 new File(Constant.pdfExportPath).mkdirs();
				 outFile.createNewFile();
			 }
		  // 1.新建document物件
			// 第一個引數是頁面大小。接下來的引數分別是左、右、上和下頁邊距。
			Document document = new Document(PageSize.A4, 50, 50, 50, 50);
			// 2.建立一個書寫器(Writer)與document物件關聯,通過書寫器(Writer)可以將文件寫入到磁碟中。
			PdfWriter writer = PdfWriter.getInstance(document,new FileOutputStream(outFile));
			// 3.開啟文件
			document.open();
			BaseFont baseFontChinese = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
			Font fontChinese =  new  Font(baseFontChinese , 11 , Font.NORMAL);
			Font font_2 = new Font(baseFontChinese,12,Font.BOLD);
			Font font = new Font(baseFontChinese, 14, Font.BOLD);
			// 4.向文件中新增內容
			Paragraph paragraph = new Paragraph(account.getRealName()+"個人簡歷",new Font(baseFontChinese,18,Font.BOLD));
			paragraph.setAlignment(1); //  設定段落居中 
			paragraph.setLeading(7.0f);;  //設定段落與其上方的距離
			document.add(paragraph);
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("基本資訊",font));
			/*
			 * 輸出一條直線
			 */
			Paragraph p1 = new Paragraph();  
			p1.add(new Chunk(new LineSeparator()));  
			document.add(p1); 
			document.add(new Paragraph("\n"));  
			 if( map.get("r_1001") != null){
			    List list = (List) map.get("r_1001");
			    JSONArray jsonArray = JSONArray.fromObject(list);
			    for(int i = 0 ; i<jsonArray.size(); i++){
			    		JSONObject jsonObject = jsonArray.getJSONObject(i);
			    		//輸出一個表格
						PdfPTable table = new PdfPTable(6);
						//第一行
						cell1 = new PdfPCell(new Phrase("姓名",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
				        cell1.setPadding(6.5f);
				        cell1.setBorderWidth(0);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        //第二行
				        cell1 = new PdfPCell(new Phrase("性別",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("sex") != null) ? (jsonObject.get("sex")) : ""),fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("出生日期",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("birthday") != null) ? (jsonObject.get("birthday")) : ""),fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("政治面貌",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("political") != null) ? (jsonObject.get("political")) : ""),fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        //第三行
				        cell1 = new PdfPCell(new Phrase("現居住地",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("city") != null) ? (jsonObject.get("city")) : ""),fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("生源地",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("province") != null) ? (jsonObject.get("province")) : ""),fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        //第四行
				        cell1 = new PdfPCell(new Phrase("手機號碼",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("mobile") != null) ? (jsonObject.get("mobile")) : ""),fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("接收郵箱",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        PdfPCell cell_e = new PdfPCell(new Phrase((String) ((jsonObject.get("email") != null) ? (jsonObject.get("email")) : ""),fontChinese));
				        cell_e.setBorderWidth(0);
				        cell_e.setPadding(6.5f);
				        cell_e.setColspan(2);
				        table.addCell(cell_e);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
						//99%  
						table.setWidthPercentage(99);  
						document.add(table);  
			                 }
			    }else{
			    		//輸出一個表格
						PdfPTable table = new PdfPTable(6);
						//第一行
						 cell1 = new PdfPCell(new Phrase("姓名",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        //第二行
				        cell1 = new PdfPCell(new Phrase("性別",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("出生日期",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("政治面貌",fontChinese));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);
				        cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        //第三行
				        cell1 = new PdfPCell(new Phrase("現居住地",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("生源地",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        //第四行
				        cell1 = new PdfPCell(new Phrase("手機號碼",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase("接收郵箱",fontChinese));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
				        cell1 = new PdfPCell(new Phrase(""));
				        cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				        table.addCell(cell1);
						//99%  
						table.setWidthPercentage(99);  
						document.add(table);  
			    	}
		
			
			//教育經歷
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("教育經歷",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
		 if(map.get("r_2001") != null){
		     List list = (List) map.get("r_2001");
		     JSONArray jsonArray = JSONArray.fromObject(list);
			 for(int i = 0 ; i<jsonArray.size(); i++){
				 JSONObject jsonObject = jsonArray.getJSONObject(i);
				  //判斷學歷
				 String degreee_num = (String) ((jsonObject.get("degree") != null) ? (jsonObject.get("degree")) : "");
			      PdfPTable edu_table = new PdfPTable(4);
			      cell1 = new PdfPCell(new Phrase(((jsonObject.get("startDate") != null) ? (jsonObject.get("startDate")) : "")+"-"+((jsonObject.get("endDate") != null) ? (jsonObject.get("endDate")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("school") != null) ? (jsonObject.get("school")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("major") != null) ? (jsonObject.get("major")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     if(jsonObject.get("rank") != null){
				    	 cell1 = new PdfPCell(new Phrase(degreee_num +"("+((jsonObject.get("rank") != null) ? (jsonObject.get("rank")) : "")+")",fontChinese));
				     }else{
				    	 cell1 = new PdfPCell(new Phrase(degreee_num,fontChinese));
				     }
				    
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     edu_table.setWidthPercentage(99);  
					 document.add(edu_table);
			 }
		 }
			 else{
				     PdfPTable edu_table = new PdfPTable(4);
			         cell1 = new PdfPCell(new Phrase("",fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase(""));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase(""));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase(""));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     edu_table.addCell(cell1);
				     edu_table.setWidthPercentage(99);  
					 document.add(edu_table);
			 }
			
			//實習經歷
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("實習經歷",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
			
			if(map.get("r_5001") != null){
	        	 List list = (List) map.get("r_5001");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				    JSONObject jsonObject = jsonArray.getJSONObject(i);
				    PdfPTable prac_table = new PdfPTable(3);
					 cell1 = new PdfPCell(new Phrase(((jsonObject.get("startDate") != null) ? (jsonObject.get("startDate")) : "")+"-"+((jsonObject.get("endDate") != null) ? (jsonObject.get("endDate")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     prac_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("companyName") != null) ? (jsonObject.get("companyName")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     prac_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("jobName") != null) ? (jsonObject.get("jobName")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     prac_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase("",fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     prac_table.addCell(cell1);
				     
				     PdfPCell cell_d1 = new PdfPCell(new Phrase((String) ((jsonObject.get("describe") != null) ? (jsonObject.get("describe")) : ""),fontChinese));
				     cell_d1.setBorderWidth(0);
				     cell_d1.setPadding(6.5f);
				     cell_d1.setColspan(2);
				     prac_table.addCell(cell_d1);
					
					prac_table.setWidthPercentage(99);  
					document.add(prac_table);
				 }
	        }else{
	        	
	        	PdfPTable prac_table = new PdfPTable(3);
				cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     prac_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase(""));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     prac_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase(""));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     prac_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase(""));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     prac_table.addCell(cell1);
				prac_table.setWidthPercentage(99);  
				document.add(prac_table);
	        }
			
			
			
			//社團經歷
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("社團經歷",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
		        if(map.get("r_1201") != null){
		        	 List list = (List) map.get("r_1201");
					 JSONArray jsonArray = JSONArray.fromObject(list);
					 for(int i = 0 ; i<jsonArray.size(); i++){
					    JSONObject jsonObject = jsonArray.getJSONObject(i);
		                PdfPTable party_table = new PdfPTable(4);
		    			cell1 = new PdfPCell(new Phrase(((jsonObject.get("startDate") != null) ? (jsonObject.get("startDate")) : "")+"-"+((jsonObject.get("endDate") != null) ? (jsonObject.get("endDate")) : ""),fontChinese));
		    		     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
		    		     party_table.addCell(cell1);
		    		     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
		    		     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
		    		     party_table.addCell(cell1);
		    		     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("level") != null) ? (jsonObject.get("level")) : ""),fontChinese));
		    		     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
		    		     party_table.addCell(cell1);
		    		     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("duty") != null) ? (jsonObject.get("duty")) : ""),fontChinese));
		    		     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
		    		     party_table.addCell(cell1);
		    		     cell1 = new PdfPCell(new Phrase("",fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     party_table.addCell(cell1);
		    		     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("descibe") != null) ? (jsonObject.get("descibe")) : ""),fontChinese));
		    		     cell1.setBorderWidth(0);
		    		     cell1.setPadding(6.5f);
		    		     cell1.setColspan(2);
		    		     party_table.addCell(cell1);
		    			party_table.setWidthPercentage(99);  
		    			document.add(party_table);
					 }
		        }else {
		        	PdfPTable party_table = new PdfPTable(3);
					cell1 = new PdfPCell(new Phrase("",fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     party_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase(""));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     party_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase(""));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     party_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase(""));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     party_table.addCell(cell1);
					party_table.setWidthPercentage(99);  
					document.add(party_table);
		        }
			
			
			//專案經驗
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("專案經驗",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
			
		      if(map.get("r_6001") != null){
		        List list = (List) map.get("r_6001");
				JSONArray jsonArray = JSONArray.fromObject(list);
				  for(int i = 0 ; i<jsonArray.size(); i++){
					    JSONObject jsonObject = jsonArray.getJSONObject(i);
					    PdfPTable pro_table = new PdfPTable(3);
					     cell1 = new PdfPCell(new Phrase(((jsonObject.get("startDate") != null) ? (jsonObject.get("startDate")).toString().trim() : "")+"-"+((jsonObject.get("endDate") != null) ? (jsonObject.get("endDate")).toString().trim() : ""),fontChinese));
					     cell1.setBorderWidth(0);
					     cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
					     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
					     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("role") != null) ? (jsonObject.get("role")) : ""),fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
					     cell1 = new PdfPCell(new Phrase("",fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
					     PdfPCell cell_d1 = new PdfPCell(new Phrase((String) ((jsonObject.get("describe") != null) ? (jsonObject.get("describe")) : ""),fontChinese));
					     cell_d1.setBorderWidth(0);cell_d1.setPadding(6.5f);
					     cell_d1.setColspan(2);
					     pro_table.addCell(cell_d1);
					     pro_table.setWidthPercentage(99); 
						 document.add(pro_table);
					 }
		        }else {
		        	    PdfPTable pro_table = new PdfPTable(3);
						cell1 = new PdfPCell(new Phrase("",fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
					     cell1 = new PdfPCell(new Phrase("",fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
					     cell1 = new PdfPCell(new Phrase("",fontChinese));
					     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					     pro_table.addCell(cell1);
						 document.add(pro_table);
				}
			
			//獎勵榮譽
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("獎勵榮譽",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
			//獎學金
			document.add(new Paragraph("   | 獎學金",font_2));
			document.add(new Paragraph("\n")); 
			 if(map.get("r_3001") != null){
	        	 List list = (List) map.get("r_3001");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				    JSONObject jsonObject = jsonArray.getJSONObject(i);
				    PdfPTable reward_table = new PdfPTable(4);
					cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("date") != null) ? (jsonObject.get("date")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     reward_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     reward_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("rank") != null) ? (jsonObject.get("rank")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     reward_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase("",fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     reward_table.addCell(cell1); 
					reward_table.setWidthPercentage(99);  
					document.add(reward_table);
				 }
	        }else{
	        	PdfPTable reward_table = new PdfPTable(4);
				cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     reward_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     reward_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     reward_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     reward_table.addCell(cell1); 
				reward_table.setWidthPercentage(99);  
				document.add(reward_table);
	        }
			
			//活動大賽
			document.add(new Paragraph("   | 活動大賽",font_2));
			document.add(new Paragraph("\n")); 
			 if(map.get("r_1301") != null){
	        	 List list = (List) map.get("r_1301");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				     JSONObject jsonObject = jsonArray.getJSONObject(i);
				     PdfPTable activity_table = new PdfPTable(4);
					 cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("time") != null) ? (jsonObject.get("time")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     activity_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     activity_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("eType") != null) ? (jsonObject.get("eType")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     activity_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("level") != null) ? (jsonObject.get("level")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     activity_table.addCell(cell1); 
					 activity_table.setWidthPercentage(99);  
					document.add(activity_table);
					
				 }
	        }else{
	        	 PdfPTable activity_table = new PdfPTable(4);
				 cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     activity_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     activity_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     activity_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     activity_table.addCell(cell1); 
				activity_table.setWidthPercentage(99);  
				document.add(activity_table);
				
	        }
			
			//技能證書
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("技能/證書",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
			 //語言能力
			document.add(new Paragraph("   | 語言能力",font_2));
			document.add(new Paragraph("\n")); 
			
			 if(map.get("r_7002") != null){
	        	 List list = (List) map.get("r_7002");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				    JSONObject jsonObject = jsonArray.getJSONObject(i);
				    PdfPTable language_table = new PdfPTable(3);
					cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("lType") != null) ? (jsonObject.get("lType")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     language_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("level") != null) ? (jsonObject.get("level")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     language_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("rank") != null) ? (jsonObject.get("rank")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     language_table.addCell(cell1);
					language_table.setWidthPercentage(99);  
					document.add(language_table);
				 }
	        }else{
	        	PdfPTable language_table = new PdfPTable(3);
				cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     language_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     language_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     language_table.addCell(cell1);
				language_table.setWidthPercentage(99);  
				document.add(language_table);
	        }
			
			
	         //證書
			document.add(new Paragraph("   | 證書",font_2));
			document.add(new Paragraph("\n")); 
			if(map.get("r_3002") != null){
	        	 List list = (List) map.get("r_3002");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				    JSONObject jsonObject = jsonArray.getJSONObject(i);
				     PdfPTable cert_table = new PdfPTable(2);
					   cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name1") != null) ? (jsonObject.get("name1")) : ""),fontChinese));
					   cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					   cert_table.addCell(cell1);
					   cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("authority") != null) ? (jsonObject.get("authority")) : ""),fontChinese));
					   cell1.setBorderWidth(0);cell1.setPadding(6.5f);
					  cert_table.addCell(cell1);
					cert_table.setWidthPercentage(99);  
					document.add(cert_table);
				 }
	        }else{
	        	PdfPTable cert_table = new PdfPTable(2);
				     cell1 = new PdfPCell(new Phrase("",fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     cert_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase("",fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     cert_table.addCell(cell1);
				     cert_table.setWidthPercentage(99);  
				     document.add(cert_table);
	        }
			
			//技能
			document.add(new Paragraph("   | 技能",font_2));
			document.add(new Paragraph("\n")); 
			 if(map.get("r_7001") != null){
	        	 List list = (List) map.get("r_7001");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				    JSONObject jsonObject = jsonArray.getJSONObject(i);
				    PdfPTable skill_table = new PdfPTable(3);
					cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
				    cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				    cell1.setColspan(3);
				    skill_table.addCell(cell1);
					skill_table.setWidthPercentage(99);  
					document.add(skill_table);
					
				 }
	        }else{
	        	
	        	 PdfPTable skill_table = new PdfPTable(3);
				 cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     skill_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     skill_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     skill_table.addCell(cell1);
				 skill_table.setWidthPercentage(99);  
				 document.add(skill_table);
				 
	        }
			
			//附加資訊
			document.add(new Paragraph("\n")); 
			document.add(new Paragraph("附加資訊",font));
			document.add(p1); 
			document.add(new Paragraph("\n")); 
			 //實驗室
			document.add(new Paragraph("   | 實驗室",font_2));
			document.add(new Paragraph("\n")); 
			
			 if(map.get("r_1401") != null){
	        	 List list = (List) map.get("r_1401");
				 JSONArray jsonArray = JSONArray.fromObject(list);
				 for(int i = 0 ; i<jsonArray.size(); i++){
				     JSONObject jsonObject = jsonArray.getJSONObject(i);
				     PdfPTable lab_table = new PdfPTable(4);
					 cell1 = new PdfPCell(new Phrase(((jsonObject.get("startDate") != null) ? (jsonObject.get("startDate")) : "")+"-"+((jsonObject.get("endDate") != null) ? (jsonObject.get("endDate")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     lab_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("name") != null) ? (jsonObject.get("name")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     lab_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase((String) ((jsonObject.get("level") != null) ? (jsonObject.get("level")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     lab_table.addCell(cell1);
				     cell1 = new PdfPCell(new Phrase("導師:  "+((jsonObject.get("instructor") != null) ? (jsonObject.get("instructor")) : ""),fontChinese));
				     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
				     lab_table.addCell(cell1); 
					 lab_table.setWidthPercentage(99);  
					 document.add(lab_table);
				 }
	        }else{
	        	 PdfPTable lab_table = new PdfPTable(4);
				 cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     lab_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     lab_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     lab_table.addCell(cell1);
			     cell1 = new PdfPCell(new Phrase("",fontChinese));
			     cell1.setBorderWidth(0);cell1.setPadding(6.5f);
			     lab_table.addCell(cell1); 
				 lab_table.setWidthPercentage(99);  
				 document.add(lab_table);
	        }
			// 5.關閉文件
			  document.close();
		   return outFile;
		 
			 } </span>