1、下载C_Lodop打印插件
下载插件官网:http://www.lodop.net/
2、pom.xml添加依赖
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.9</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-asian</artifactId>
<version>5.2.0</version>
</dependency>
3、controller层
该代码是生成了一个表格,把页面传过去的参数通过findByForeach()方法找出来,用for循环叠加表格的行数。
@RequestMapping("/scorePDF")
public Object scorePDF (@RequestParam("nums") Object nums, HttpServletResponse response) throws Exception {
String datas = nums.toString();
String[] str = datas.split(",");
List<String> data = new ArrayList<String>();
for (int i = 0; i < str.length; i++) {
data.add(str[i]);
}
//用于存储listScore的每个for循环的值
List list = new ArrayList<>();
//查找选中的成绩信息
List<StuExt> listScore = stuService