java使用Abobe Acrobat DC生成模板
說明:轉(zhuǎn)換成pdf格式
二、Abobe Acrobat DC圖解利用Abobe Acrobat DC打開pdf
步驟:文件 ---->創(chuàng)建------>創(chuàng)建表單----->選擇文件(你轉(zhuǎn)換成pdf文件)
這里是所要增加的文本域、圖片域等功能按鈕
在你需要的位置增加你說要的功能完成之后進(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); //對圖片進(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)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!
相關(guān)文章:
1. python爬蟲實(shí)戰(zhàn)之制作屬于自己的一個(gè)IP代理模塊2. Spring如何使用xml創(chuàng)建bean對象3. Android Studio設(shè)置顏色拾色器工具Color Picker教程4. HTML 絕對路徑與相對路徑概念詳細(xì)5. python實(shí)現(xiàn)在內(nèi)存中讀寫str和二進(jìn)制數(shù)據(jù)代碼6. python實(shí)現(xiàn)PolynomialFeatures多項(xiàng)式的方法7. Vue proxyTable配置多個(gè)接口地址,解決跨域的問題8. Java程序的編碼規(guī)范(6)9. python 利用toapi庫自動生成api10. IDEA部署Docker到WSL2的詳細(xì)過程
