easy2print-pdf-core

This is an extension library to easy print pdf. 方便大家填写pdf 第三方库 项目地址:https://github.com/zhuobinchan/easy2printPDF

License

License

Categories

Categories

PDF Data
GroupId

GroupId

com.github.zhuobinchan
ArtifactId

ArtifactId

easy2print-pdf-core
Last Version

Last Version

1.1
Release Date

Release Date

Type

Type

jar
Description

Description

easy2print-pdf-core
This is an extension library to easy print pdf. 方便大家填写pdf 第三方库 项目地址:https://github.com/zhuobinchan/easy2printPDF
Project URL

Project URL

https://github.com/zhuobinchan/easy2printPDF
Source Code Management

Source Code Management

https://github.com/zhuobinchan/easy2printPDF

Download easy2print-pdf-core

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.zhuobinchan/easy2print-pdf-core/ -->
<dependency>
    <groupId>com.github.zhuobinchan</groupId>
    <artifactId>easy2print-pdf-core</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.zhuobinchan/easy2print-pdf-core/
implementation 'com.github.zhuobinchan:easy2print-pdf-core:1.1'
// https://jarcasting.com/artifacts/com.github.zhuobinchan/easy2print-pdf-core/
implementation ("com.github.zhuobinchan:easy2print-pdf-core:1.1")
'com.github.zhuobinchan:easy2print-pdf-core:jar:1.1'
<dependency org="com.github.zhuobinchan" name="easy2print-pdf-core" rev="1.1">
  <artifact name="easy2print-pdf-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.zhuobinchan', module='easy2print-pdf-core', version='1.1')
)
libraryDependencies += "com.github.zhuobinchan" % "easy2print-pdf-core" % "1.1"
[com.github.zhuobinchan/easy2print-pdf-core "1.1"]

Dependencies

compile (1)

Group / Artifact Type Version
com.itextpdf : itext7-core pom 7.1.12

test (1)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter jar 5.6.2

Project Modules

There are no modules declared in this project.

easy2printPDF

使用模板的方式 写属于你的pdf

itext7 中文文档 https://github.com/iTextCN/itext7-in-mandarin

TODO LIST

功能 完成度
表单填充 done
图片填充 本地图片路径已经支持,网络图片需要或者字节流图片暂时无法支持
列表动态填充 will rebuild

1、 对pdf整理表单格式,如下图 avatar

2、依赖 itext 框架 封装了一层 模板层,可以很方便的填充pdf

<dependency>
  <groupId>com.github.zhuobinchan</groupId>
  <artifactId>easy2print-pdf-core</artifactId>
  <version>1.1</version>
</dependency>

3、测试类,相关东西放在项目的test,resource文件下

public class PdfTest {
    @Test
        public void test2() {
            InvoiceCodePdfModel model = new InvoiceCodePdfModel();
            model.setCode_1("123");
            model.setMachineNumber("abc哈哈");
    
            ArrayList<InvoiceCodeServiceParam> objects = new ArrayList();
            InvoiceCodeServiceParam invoiceCodeServiceParam = new InvoiceCodeServiceParam();
            invoiceCodeServiceParam.setServiceName("setServiceName1");
            objects.add(invoiceCodeServiceParam);
            model.setParams(objects);
    
    //        model.setImage1("https://raw.githubusercontent.com/alibaba/easyexcel/master/src/test/resources/converter/img.jpg");
            model.setImage1("D:\\idea_project\\easy2printPDF\\easy2printPDF\\easy2print-pdf-core\\src\\test\\resources\\model\\image.gif");
    
            System.out.println(PdfModelUtils.printPdf("D:\\idea_project\\easy2printPDF\\easy2printPDF\\easy2print-pdf-core\\src\\test\\resources\\model\\7124eb8105c3d7de930d.pdf", "D:\\idea_project\\easy2printPDF\\easy2printPDF\\easy2print-pdf-core\\src\\test\\resources\\pdf\\", model, InvoiceCodePdfModel.class));
        }
    
    
        public static class InvoiceCodePdfModel {
            @PdfField(fieldName = "code_1")
            @PdfFieldStyle
            private String code_1; // 发票左上角代码
    
            @PdfField(fieldName = "machineNumber")
            @PdfFieldStyle
            private String machineNumber; // 机器编号
    
            @PdfField(fieldName = "params", ignoreFieldNamePrefix4Collection = true)
            private List<InvoiceCodeServiceParam> params;
    
            //图片填充
            @PdfField(fieldName = "image1", converter = ImagePathConverter.class)
            private String image1;
            //get set...
        }
    
        public static class InvoiceCodeServiceParam {
            @PdfField(fieldName = "serviceName_${COLLECTION_INDEX}")
            private String serviceName;
            //get set...
        }
}

Versions

Version
1.1
1.0