/**
     * pdf模板导出
     */
    @Test
    public void exportPDFTemplate() throws Exception {
        //导出数据
        Map<String,String> params = new HashMap<>();
        for(int i=1;i<=26;i++){
            params.put("fill_"+i,String.valueOf(i));
        }

        //字体
        BaseFont bf = BaseFont.createFont("simsun.ttc,1" , BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
        // 读取pdf模板
        PdfReader reader = new PdfReader("D:\\北京发货单.pdf");
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        PdfStamper stamper = new PdfStamper(reader, bos);
        AcroFields form = stamper.getAcroFields();
        //文字类的内容处理
        form.addSubstitutionFont(bf);
        for(String key : params.keySet()){
            String value = params.get(key);
            form.setField(key,value);
        }

        //false可以编辑,true不可以编辑
        stamper.setFormFlattening(true);
        stamper.close();
        Document doc = new Document();


        File saveFile = new File("D:/");
        if (!saveFile.exists()) {
            saveFile.mkdirs();
        }

        FileOutputStream fos = new FileOutputStream("D:/testExportPDF.pdf");
        PdfCopy copy= new PdfCopy(doc, fos);
        doc.open();
        PdfImportedPage importPage = copy.getImportedPage(new PdfReader(bos.toByteArray()), 1);
        copy.addPage(importPage);
        doc.close();
        fos.close();
    }

<!--pdf导出工具-->
<dependency>
    <groupId>com.itextpdf</groupId>
    <artifactId>itextpdf</artifactId>
    <version>5.4.3</version>
</dependency>
pdf模板下载


https://files.cnblogs.com/files/xinchi/%E5%8C%97%E4%BA%AC%E5%8F%91%E8%B4%A7%E5%8D%95.zip