JAVA小记-生成PDF文件
项目场景:
例如:项目中需要生成PDF文件
项目使用情况
1、引入pom.xml
<!--pdf相关依赖--> <dependency><groupId>com.itextpdf</groupId><artifactId>itextpdf</artifactId><version>5.5.13</version> </dependency> <dependency><groupId>com.itextpdf</groupId><artifactId>itext-asian</artifactId><version>5.2.0</version> </dependency>
2、项目中部分代码
// 1.新建document对象Document document = new Document(PageSize.A4);// 建立一个Document对象// 2.建立一个书写器(Writer)与document对象关联String path = Thread.currentThread().getContextClassLoader().getResource("").getPath();long id = System.currentTimeMillis();String showFileName = "通知单.pdf";String localFileName =