java使用Abobe Acrobat DC生成模板
說(shuō)明:轉(zhuǎn)換成pdf格式
二、Abobe Acrobat DC圖解利用Abobe Acrobat DC打開(kāi)pdf
步驟:文件 ---->創(chuàng)建------>創(chuàng)建表單----->選擇文件(你轉(zhuǎn)換成pdf文件)
這里是所要增加的文本域、圖片域等功能按鈕
在你需要的位置增加你說(shuō)要的功能完成之后進(jìn)行保存
環(huán)境maven
<dependency><groupId>com.itextpdf</groupId><artifactId>itext7-core</artifactId><version>7.1.13</version><type>pom</type></dependency>
生成的模板文件放到適當(dāng)?shù)奈恢?/b>
所需要生成新的pdf代碼
public @ResponseBody Object getFaceVerificationPdf(GzFaceVerification gzFaceVerification, HttpServletRequest request) throws IOException {try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { try (PdfDocument document = new PdfDocument(new PdfReader( new ClassPathResource('static/moban.pdf').getInputStream()), new PdfWriter(outputStream))) { PdfAcroForm pdfAcroForm = PdfAcroForm.getAcroForm(document, true); //對(duì)圖片進(jìn)行處理(如果不處理在模板中顯示不出圖片) PdfFormField pdfFormField = pdfAcroForm.getField('frontIdCardUrl'); InputStream is = new FileInputStream(new File(gzFaceVerification.getFrontIdCardUrl())); String str = Base64.encodeBytes(StreamUtil.inputStreamToArray(is)); pdfFormField.setValue(str); pdfAcroForm.addField(pdfFormField); PdfFormField pdfFormField1 = pdfAcroForm.getField('reverseIdCardUrl'); InputStream is1 = new FileInputStream(new File(gzFaceVerification.getReverseIdCardUrl())); String str1 = Base64.encodeBytes(StreamUtil.inputStreamToArray(is1)); pdfFormField1.setValue(str1); pdfAcroForm.addField(pdfFormField1); PdfFormField pdfFormField2 = pdfAcroForm.getField('photo'); InputStream is2 = new FileInputStream(new File(gzFaceVerification.getPhoto())); String str2 = Base64.encodeBytes(StreamUtil.inputStreamToArray(is2)); pdfFormField2.setValue(str2); pdfAcroForm.addField(pdfFormField2); pdfAcroForm.getField('frontIdCardUrl').setValue(gzFaceVerification.getFrontIdCardUrl()); pdfAcroForm.getField('reverseIdCardUrl').setValue(gzFaceVerification.getReverseIdCardUrl()); pdfAcroForm.getField('photo').setValue(gzFaceVerification.getPhoto()); pdfAcroForm.getField('comparisonResults').setValue(gzFaceVerification.getComparisonResults()); pdfAcroForm.getField('createTime').setValue(gzFaceVerification.getCreateTime()); pdfAcroForm.flattenFields(); } HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_PDF); httpHeaders.setContentDispositionFormData('attachment', 'test.pdf', Charset.forName('UTF-8')); return ResponseEntity.ok().headers(httpHeaders).body(outputStream.toByteArray());} }
到此這篇關(guān)于java使用Abobe Acrobat DC生成模板的文章就介紹到這了,更多相關(guān)Abobe Acrobat DC生成模板內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. UDDI FAQs2. jsp實(shí)現(xiàn)textarea中的文字保存換行空格存到數(shù)據(jù)庫(kù)的方法3. WML的簡(jiǎn)單例子及編輯、測(cè)試方法第1/2頁(yè)4. IE6/IE7/IE8/IE9中tbody的innerHTML不能賦值的完美解決方案5. 阿里前端開(kāi)發(fā)中的規(guī)范要求6. 得到XML文檔大小的方法7. CSS可以做的幾個(gè)令你嘆為觀止的實(shí)例分享8. CSS3實(shí)現(xiàn)動(dòng)態(tài)翻牌效果 仿百度貼吧3D翻牌一次動(dòng)畫(huà)特效9. ASP常用日期格式化函數(shù) FormatDate()10. 概述IE和SQL2k開(kāi)發(fā)一個(gè)XML聊天程序
