1-引入POM
<!-- PDF打印-jasper -->
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.12.2</version>
<exclusions>
<exclusion>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.lowagie</groupId>
<artifactId>itext</artifactId>
<version>2.1.7</version>
</dependency>
2-打印代码
controller层:
@ApiOperation(value = "打印PDF", notes = "print")
@GetMapping("/print")
public void print(String search, HttpServletResponse response) {
try {

文章介绍了如何在SpringBoot项目中使用JasperReports库来生成并打印PDF报表,包括Maven依赖配置,Controller层的接口调用,以及ServiceImpl层的具体实现,展示了如何从数据库获取数据并填充到JasperReport模板中。
最低0.47元/天 解锁文章
4895





