本篇文章小编给大家分享一下java使用Abobe Acrobat DC生成模板代码示例,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。
一、利用word生成一个文档转成pdf
说明:转换成pdf格式
二、Abobe Acrobat DC图解
利用Abobe Acrobat DC打开pdf
步骤:文件 ---->创建------>创建表单----->选择文件(你转换成pdf文件)
这里是所要增加的文本域、图片域等功能按钮
在你需要的位置增加你说要的功能完成之后进行保存
三、java后台代码
环境maven
com.itextpdf itext7-core 7.1.13 pom
生成的模板文件放到适当的位置
所需要生成新的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); //对图片进行处理(如果不处理在模板中显示不出图片) 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()); } }
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔