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. xpath簡(jiǎn)介_(kāi)動(dòng)力節(jié)點(diǎn)Java學(xué)院整理2. 解析原生JS getComputedStyle3. XHTML 1.0:標(biāo)記新的開(kāi)端4. JSP的Cookie在登錄中的使用5. HTML DOM setInterval和clearInterval方法案例詳解6. 詳解瀏覽器的緩存機(jī)制7. 詳解盒子端CSS動(dòng)畫(huà)性能提升8. 測(cè)試模式 - XSL教程 - 59. 讀大數(shù)據(jù)量的XML文件的讀取問(wèn)題10. ASP實(shí)現(xiàn)加法驗(yàn)證碼
