前言:
现在有很多pdf版本的协议,需要动态填写用户相关参数和粘贴用户相关图片,如果项目jdk版本为1.6或更低请使用itext5实现,详情见我另外一章itext5实现参数和图片替换的文章,itext7不支持jdk1.6(亲测);
引入的依赖包如下:
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext7-core</artifactId>
<version>7.1.2</version>
<type>pom</type>
</dependency>
1.参数替换代码:
public class ReplaceStream extends GenericTest {
public static final String DEST = "./target/test/resources/sandbox/stamper/replace_stream.pdf";
public static final String SRC = "./src/test/resources/pdfs/hello.pdf";
public static void main(String[] args) throws Exception {
File file = new File(DEST);