|
@@ -0,0 +1,462 @@
|
|
|
+package com.qmth.distributed.print.business.util;
|
|
|
+
|
|
|
+import com.itextpdf.text.*;
|
|
|
+import com.itextpdf.text.pdf.*;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.ExamStudentCourseDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.PdfDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.PdfPackageDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.PdfSignDto;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamDetail;
|
|
|
+import com.qmth.distributed.print.business.entity.ExamDetailCourse;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import com.qmth.teachcloud.common.util.ConvertUtil;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * pdf模板内容填充
|
|
|
+ */
|
|
|
+@Component
|
|
|
+public class CreatePrintPdfUtil {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CreatePrintPdfUtil.class);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 签到表生成
|
|
|
+ *
|
|
|
+ * @param response response
|
|
|
+ * @param pdfFillDto 签到表数据
|
|
|
+ * @param destFileName 文件名
|
|
|
+ * @param saveLocal 是事保存本地文件
|
|
|
+ */
|
|
|
+ public void createSignPdf(HttpServletResponse response, PdfSignDto pdfFillDto, String destFileName, boolean saveLocal) throws Exception {
|
|
|
+
|
|
|
+ // 1:建立Document对象实例
|
|
|
+ Document document = new Document(PageSize.A4, 36.0F, 36.0F, 40F, 36.0F);
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+ try {
|
|
|
+ // 2:建立一个PDF 写入器与document对象关联通过书写器(Writer)可以将文档写入到磁盘中
|
|
|
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, baos);
|
|
|
+
|
|
|
+ //3、设置pdf页眉和页脚和水印
|
|
|
+ MyHeaderFooter headerFooter = new MyHeaderFooter();
|
|
|
+ pdfWriter.setPageEvent(headerFooter);
|
|
|
+
|
|
|
+ // 3:打开文档
|
|
|
+ document.open();
|
|
|
+ //生成pdf
|
|
|
+ this.generateSignPDF(document, pdfWriter, pdfFillDto);
|
|
|
+ // 5:关闭文档
|
|
|
+ document.close();
|
|
|
+ } catch (DocumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (saveLocal) {
|
|
|
+ PdfFillUtils.saveFile(baos, destFileName);
|
|
|
+ } else {
|
|
|
+ ConvertUtil.outputFile(response, baos, destFileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卷袋贴生成
|
|
|
+ *
|
|
|
+ * @param response response
|
|
|
+ * @param pdfPackageDto 卷袋贴参数
|
|
|
+ * @param destFileName 保存文件名
|
|
|
+ * @param saveLocal 是否保存本地
|
|
|
+ */
|
|
|
+ public void createPackagePdf(HttpServletResponse response, PdfPackageDto pdfPackageDto, String destFileName, boolean saveLocal) throws Exception {
|
|
|
+
|
|
|
+ // 1:建立Document对象实例
|
|
|
+ Document document = new Document(PageSize.A4, 36.0F, 36.0F, 40F, 36.0F);
|
|
|
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
|
+ try {
|
|
|
+ // 2:建立一个PDF 写入器与document对象关联通过书写器(Writer)可以将文档写入到磁盘中
|
|
|
+ PdfWriter pdfWriter = PdfWriter.getInstance(document, baos);
|
|
|
+ // 3:打开文档
|
|
|
+ document.open();
|
|
|
+ //生成pdf
|
|
|
+ this.generatePackagePDF(document, pdfWriter, pdfPackageDto);
|
|
|
+ // 5:关闭文档
|
|
|
+ document.close();
|
|
|
+ } catch (DocumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ if (saveLocal) {
|
|
|
+ PdfFillUtils.saveFile(baos, destFileName);
|
|
|
+ } else {
|
|
|
+ ConvertUtil.outputFile(response, baos, destFileName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成签到表pdf文件
|
|
|
+ *
|
|
|
+ * @param document document
|
|
|
+ * @param pdfWriter pdfWriter
|
|
|
+ * @param pdfFillDto 签到表数据
|
|
|
+ */
|
|
|
+ private void generateSignPDF(Document document, PdfWriter pdfWriter, PdfSignDto pdfFillDto) throws DocumentException {
|
|
|
+ // 空格
|
|
|
+ Paragraph blank = new Paragraph(" ");
|
|
|
+ // 标题table
|
|
|
+ PdfPTable titleTable = PdfFillUtils.createTable(new float[]{33, 34, 33});
|
|
|
+ titleTable.addCell(PdfFillUtils.createCell("", null, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
|
|
|
+ titleTable.addCell(PdfFillUtils.createCell(pdfFillDto.getTitle(), PdfFillUtils.textFont18, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
|
|
|
+ // 条码
|
|
|
+ Image code128Image = PdfFillUtils.createBarcode(pdfWriter, pdfFillDto.getPackageNumber(), false, null, null);
|
|
|
+ code128Image.scalePercent(100);
|
|
|
+ titleTable.addCell(PdfFillUtils.createCell(code128Image, 50f, 15, 3));
|
|
|
+ document.add(titleTable);
|
|
|
+
|
|
|
+
|
|
|
+ // 基础信息表格
|
|
|
+ PdfPTable basicTable = PdfFillUtils.createTable(6);
|
|
|
+ List<Map<String, String>> basicPlate = pdfFillDto.getBasicPlate();
|
|
|
+ for (Map<String, String> stringMap : basicPlate) {
|
|
|
+ basicTable.addCell(PdfFillUtils.createCell(stringMap.get("name") + ":" + stringMap.get("value"), PdfFillUtils.textFont12, null, 16f, Element.ALIGN_LEFT, 0, 1, 3));
|
|
|
+ }
|
|
|
+ document.add(basicTable);
|
|
|
+
|
|
|
+ document.add(blank);
|
|
|
+
|
|
|
+ //表头
|
|
|
+ Map<String, String> studentHeadPlate = pdfFillDto.getStudentHeadPlate();
|
|
|
+ //计算表格宽度
|
|
|
+ float[] columnWidth = chooseColumnWidth(studentHeadPlate.size());
|
|
|
+ int columnCount = studentHeadPlate.size();
|
|
|
+
|
|
|
+ PdfPTable studentTable = PdfFillUtils.createTable(columnWidth);
|
|
|
+ String[] headKeys = new String[columnCount * 2];
|
|
|
+
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ int j = 0;
|
|
|
+ for (Map.Entry<String, String> entry : studentHeadPlate.entrySet()) {
|
|
|
+ headKeys[columnCount * i + j] = entry.getKey();
|
|
|
+ studentTable.addCell(PdfFillUtils.createCell(entry.getValue(), PdfFillUtils.textFont12, BaseColor.GRAY, 16f, Element.ALIGN_CENTER, 0, 1, 1));
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据
|
|
|
+ List<Map<String, String>> studentPlate = pdfFillDto.getStudentPlate();
|
|
|
+ int studentPlateCount = studentPlate.size();
|
|
|
+ int forCount = studentPlateCount % 2 == 0 ? studentPlateCount / 2 : studentPlateCount / 2 + 1;
|
|
|
+
|
|
|
+ for (int i = 0; i < forCount; i++) {
|
|
|
+ Map<String, String> stringMap1 = studentPlate.get(2 * i);
|
|
|
+ for (int j = 0; j < stringMap1.size(); j++) {
|
|
|
+ String value = stringMap1.get(headKeys[j]);
|
|
|
+ studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (studentPlateCount % 2 > 0 && 2 * i + 1 == studentPlate.size()) {
|
|
|
+ for (int i1 = 0; i1 < columnCount; i1++) {
|
|
|
+ studentTable.addCell(PdfFillUtils.createCell("", PdfFillUtils.textFont12, null, 0, Element.ALIGN_CENTER, 0, 1, 1));
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, String> stringMap2 = studentPlate.get(2 * i + 1);
|
|
|
+ for (int j = 0; j < stringMap2.size(); j++) {
|
|
|
+ String value = stringMap2.get(headKeys[j + columnCount]);
|
|
|
+ studentTable.addCell(PdfFillUtils.createCell(value, chooseFont(value, columnWidth[j + columnCount]), null, 0, Element.ALIGN_CENTER, 0, 1, 1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ document.add(studentTable);
|
|
|
+
|
|
|
+ document.add(blank);
|
|
|
+
|
|
|
+ Paragraph pDate = new Paragraph(" 年 月 日", PdfFillUtils.textFont12);
|
|
|
+ pDate.setAlignment(Element.ALIGN_RIGHT);
|
|
|
+ pDate.setIndentationRight(20);
|
|
|
+
|
|
|
+ PdfPTable signTable = new PdfPTable(4);
|
|
|
+ signTable.setWidthPercentage(100);// 表格宽度为100%
|
|
|
+ // 备注
|
|
|
+ PdfPCell cell34 = new PdfPCell();
|
|
|
+ cell34.setBorderWidth(0.5F);
|
|
|
+ cell34.setMinimumHeight(20);
|
|
|
+ cell34.setPhrase(new Paragraph("监考老师签名处", PdfFillUtils.textFont12));
|
|
|
+ cell34.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ cell34.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ signTable.addCell(cell34);
|
|
|
+ PdfPCell cell35 = new PdfPCell();
|
|
|
+ cell35.setBorderWidth(0.5F);
|
|
|
+ cell35.setColspan(3);
|
|
|
+ cell35.addElement(blank);
|
|
|
+ cell35.addElement(pDate);
|
|
|
+ cell35.addElement(blank);
|
|
|
+ signTable.addCell(cell35);
|
|
|
+
|
|
|
+ try {
|
|
|
+ document.add(signTable);
|
|
|
+ } catch (DocumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 卷袋贴生成方法
|
|
|
+ *
|
|
|
+ * @param document document
|
|
|
+ * @param pdfWriter pdfWriter
|
|
|
+ * @param pdfPackageDto 卷袋贴数据
|
|
|
+ */
|
|
|
+ private void generatePackagePDF(Document document, PdfWriter pdfWriter, PdfPackageDto pdfPackageDto) {
|
|
|
+ try {
|
|
|
+ // 空格
|
|
|
+ Paragraph blank = new Paragraph(" ");
|
|
|
+ // 标题table
|
|
|
+ PdfPTable titleTable = PdfFillUtils.createTable(new float[]{33, 34, 33});
|
|
|
+ titleTable.addCell(PdfFillUtils.createCell("", null, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
|
|
|
+ titleTable.addCell(PdfFillUtils.createCell(pdfPackageDto.getTitle(), PdfFillUtils.textFont28, null, 50f, Element.ALIGN_CENTER, 15, 3, 1));
|
|
|
+ // 条码
|
|
|
+ Image code128Image = PdfFillUtils.createBarcode(pdfWriter, pdfPackageDto.getPackageNumber(), false, null, null);
|
|
|
+ code128Image.scalePercent(100);
|
|
|
+ titleTable.addCell(PdfFillUtils.createCell(code128Image, 50f, 15, 3));
|
|
|
+ document.add(titleTable);
|
|
|
+
|
|
|
+ document.add(blank);
|
|
|
+
|
|
|
+ // 基础信息表格
|
|
|
+ PdfPTable basicTable = PdfFillUtils.createTable(1);
|
|
|
+ List<Map<String, String>> basicPlate = pdfPackageDto.getBasicPlate();
|
|
|
+ for (Map<String, String> stringMap : basicPlate) {
|
|
|
+ basicTable.addCell(PdfFillUtils.createCell(stringMap.get("name") + ":" + stringMap.get("value"), PdfFillUtils.textFont24, 50f, Element.ALIGN_LEFT, 20f));
|
|
|
+ document.add(blank);
|
|
|
+ }
|
|
|
+ document.add(basicTable);
|
|
|
+ document.add(blank);
|
|
|
+ } catch (DocumentException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 签到表考生签到table表头宽度选择
|
|
|
+ *
|
|
|
+ * @param size 表头字段数量
|
|
|
+ */
|
|
|
+ private float[] chooseColumnWidth(int size) {
|
|
|
+ float[] columnWidth;
|
|
|
+ if (size == 1) {
|
|
|
+ columnWidth = new float[]{50, 50};
|
|
|
+ } else if (size == 2) {
|
|
|
+ columnWidth = new float[]{20, 30, 20, 30};
|
|
|
+ } else if (size == 3) {
|
|
|
+ columnWidth = new float[]{10, 25, 25, 10, 25, 25};
|
|
|
+ } else if (size == 4) {
|
|
|
+ columnWidth = new float[]{6, 12, 16, 16, 6, 12, 16, 16};
|
|
|
+ } else if (size == 5) {
|
|
|
+ columnWidth = new float[]{6, 10, 11, 12, 11, 6, 10, 11, 12, 11};
|
|
|
+ } else if (size == 6) {
|
|
|
+ columnWidth = new float[]{6, 9, 9, 9, 9, 8, 6, 9, 9, 9, 9, 8};
|
|
|
+ } else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("签到表最多只能显示6个信息");
|
|
|
+ }
|
|
|
+ return columnWidth;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据表格大小,选择字号
|
|
|
+ *
|
|
|
+ * @param value 值
|
|
|
+ * @param percent 宽度
|
|
|
+ */
|
|
|
+ private Font chooseFont(String value, float percent) {
|
|
|
+ if (value.length() < percent) {
|
|
|
+ return PdfFillUtils.textFont12;
|
|
|
+ } else if (value.length() >= percent && value.length() < 1.5 * percent) {
|
|
|
+ return PdfFillUtils.textFont10;
|
|
|
+ } else if (value.length() >= 1.5 * percent && value.length() < 2 * percent) {
|
|
|
+ return PdfFillUtils.textFont9;
|
|
|
+ }
|
|
|
+ return PdfFillUtils.textFont8;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 内部类
|
|
|
+ * 添加页眉、页脚
|
|
|
+ */
|
|
|
+ public static class MyHeaderFooter extends PdfPageEventHelper {
|
|
|
+ // 总页数
|
|
|
+ PdfTemplate totalPage;
|
|
|
+
|
|
|
+ // 打开文档时,创建一个总页数的模版
|
|
|
+ @Override
|
|
|
+ public void onOpenDocument(PdfWriter writer, Document document) {
|
|
|
+ PdfContentByte cb = writer.getDirectContent();
|
|
|
+ totalPage = cb.createTemplate(30, 16);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 一页加载完成触发,写入页眉和页脚
|
|
|
+ @Override
|
|
|
+ public void onEndPage(PdfWriter writer, Document document) {
|
|
|
+ PdfPTable table = new PdfPTable(3);
|
|
|
+ try {
|
|
|
+ table.setTotalWidth(PageSize.A4.getWidth() - 80);
|
|
|
+ table.setWidths(new int[]{24, 24, 3});
|
|
|
+ table.setLockedWidth(true);
|
|
|
+ table.getDefaultCell().setFixedHeight(-10);
|
|
|
+ table.getDefaultCell().setBorder(Rectangle.BOTTOM);
|
|
|
+ table.getDefaultCell().setBorderWidth(0.5f);
|
|
|
+
|
|
|
+ table.addCell(new Paragraph("", PdfFillUtils.textFont8));// 可以直接使用addCell(str),不过不能指定字体,中文无法显示
|
|
|
+ table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
|
|
|
+ table.addCell(new Paragraph("第" + writer.getPageNumber() + "页 /", PdfFillUtils.textFont8));
|
|
|
+ // 总页数
|
|
|
+ PdfPCell cell = new PdfPCell(Image.getInstance(totalPage));
|
|
|
+ cell.setBorder(Rectangle.BOTTOM);
|
|
|
+ table.addCell(cell);
|
|
|
+ // 将页眉写到document中,位置可以指定,指定到下面就是页脚
|
|
|
+ // 页眉
|
|
|
+ table.writeSelectedRows(0, -1, 40, PageSize.A4.getHeight() - 20, writer.getDirectContent());
|
|
|
+ // 页脚
|
|
|
+// table.writeSelectedRows(0, -1, 40, 40, writer.getDirectContent());
|
|
|
+ } catch (Exception de) {
|
|
|
+ throw new ExceptionConverter(de);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 全部完成后,将总页数的pdf模版写到指定位置
|
|
|
+ @Override
|
|
|
+ public void onCloseDocument(PdfWriter writer, Document document) {
|
|
|
+ String text = "共" + (writer.getPageNumber()) + "页";
|
|
|
+ ColumnText.showTextAligned(totalPage, Element.ALIGN_LEFT, new Paragraph(text, PdfFillUtils.textFont8), 2, 6, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测试方法
|
|
|
+ *
|
|
|
+ * @param args
|
|
|
+ */
|
|
|
+ public static void main(String[] args) {
|
|
|
+ PdfSignDto pdfFillDto = new PdfSignDto();
|
|
|
+ pdfFillDto.setTitle("测试签到表");
|
|
|
+ pdfFillDto.setPackageNumber("200032324");
|
|
|
+
|
|
|
+ // 基础信息
|
|
|
+ List<Map<String, String>> basicPlate = new ArrayList<>();
|
|
|
+ Map<String, String> basicMap = new HashMap<>();
|
|
|
+ basicMap.put("code", "courseCode");
|
|
|
+ basicMap.put("name", "课程代码");
|
|
|
+ basicMap.put("value", "高等数学");
|
|
|
+ basicPlate.add(basicMap);
|
|
|
+
|
|
|
+ basicMap = new HashMap<>();
|
|
|
+ basicMap.put("code", "paperNumber");
|
|
|
+ basicMap.put("name", "试卷编号");
|
|
|
+ basicMap.put("value", "bh001");
|
|
|
+ basicPlate.add(basicMap);
|
|
|
+
|
|
|
+ basicMap = new HashMap<>();
|
|
|
+ basicMap.put("code", "examTime");
|
|
|
+ basicMap.put("name", "考试时间");
|
|
|
+ basicMap.put("value", "2022-09-10 9:00-12:00");
|
|
|
+ basicPlate.add(basicMap);
|
|
|
+
|
|
|
+ basicMap = new HashMap<>();
|
|
|
+ basicMap.put("code", "examRoom");
|
|
|
+ basicMap.put("name", "考试地点");
|
|
|
+ basicMap.put("value", "教学楼301");
|
|
|
+ basicPlate.add(basicMap);
|
|
|
+
|
|
|
+ basicMap = new HashMap<>();
|
|
|
+ basicMap.put("code", "examCount");
|
|
|
+ basicMap.put("name", "应考人数");
|
|
|
+ basicMap.put("value", "61");
|
|
|
+ basicPlate.add(basicMap);
|
|
|
+
|
|
|
+ basicMap = new HashMap<>();
|
|
|
+ basicMap.put("code", "actualExamCount");
|
|
|
+ basicMap.put("name", "实考人数");
|
|
|
+ basicMap.put("value", "");
|
|
|
+ basicPlate.add(basicMap);
|
|
|
+
|
|
|
+ pdfFillDto.setBasicPlate(basicPlate);
|
|
|
+
|
|
|
+ // 表头信息
|
|
|
+ Map<String, String> studentHeadPlateMap = new LinkedHashMap<>();
|
|
|
+ studentHeadPlateMap.put("seq", "序号");
|
|
|
+ studentHeadPlateMap.put("studentCode", "学号");
|
|
|
+ studentHeadPlateMap.put("studentName", "姓名");
|
|
|
+ studentHeadPlateMap.put("className", "班级");
|
|
|
+ studentHeadPlateMap.put("studentSign", "签名");
|
|
|
+ pdfFillDto.setStudentHeadPlate(studentHeadPlateMap);
|
|
|
+
|
|
|
+ // 考生信息
|
|
|
+ List<Map<String, String>> studentPlate = new ArrayList<>();
|
|
|
+ for (int i = 0; i < 61; i++) {
|
|
|
+ Map<String, String> studentMap = new HashMap<>();
|
|
|
+ String seq = String.valueOf(i + 1);
|
|
|
+ studentMap.put("seq", seq);
|
|
|
+ studentMap.put("studentCode", "20010" + String.format("%03d", i + 1));
|
|
|
+ if (i > 10 && i < 20) {
|
|
|
+ studentMap.put("studentName", "学生" + String.format("%06d", i + 1));
|
|
|
+ } else if (i > 34 && i < 50) {
|
|
|
+ studentMap.put("studentName", "学生" + String.format("%010d", i + 1));
|
|
|
+ } else {
|
|
|
+ studentMap.put("studentName", "学生" + seq);
|
|
|
+ }
|
|
|
+ studentMap.put("className", "班级1");
|
|
|
+ studentMap.put("studentSign", "");
|
|
|
+ studentPlate.add(studentMap);
|
|
|
+ }
|
|
|
+ pdfFillDto.setStudentPlate(studentPlate);
|
|
|
+
|
|
|
+ PdfPackageDto pdfPackageDto = new PdfPackageDto();
|
|
|
+ pdfPackageDto.setTitle("测试卷袋贴");
|
|
|
+ pdfPackageDto.setPackageNumber("20000213134");
|
|
|
+
|
|
|
+ // 基础信息
|
|
|
+ List<Map<String, String>> basicPlate1 = new ArrayList<>();
|
|
|
+ Map<String, String> basicMap1 = new HashMap<>();
|
|
|
+ basicMap1.put("code", "courseCode");
|
|
|
+ basicMap1.put("name", "课程代码");
|
|
|
+ basicMap1.put("value", "高等数学");
|
|
|
+ basicPlate1.add(basicMap1);
|
|
|
+
|
|
|
+ basicMap1 = new HashMap<>();
|
|
|
+ basicMap1.put("code", "paperNumber");
|
|
|
+ basicMap1.put("name", "试卷编号");
|
|
|
+ basicMap1.put("value", "bh001");
|
|
|
+ basicPlate1.add(basicMap1);
|
|
|
+
|
|
|
+ basicMap1 = new HashMap<>();
|
|
|
+ basicMap1.put("code", "examTime");
|
|
|
+ basicMap1.put("name", "考试时间");
|
|
|
+ basicMap1.put("value", "2022-09-10 9:00-12:00");
|
|
|
+ basicPlate1.add(basicMap1);
|
|
|
+
|
|
|
+ basicMap1 = new HashMap<>();
|
|
|
+ basicMap1.put("code", "examRoom");
|
|
|
+ basicMap1.put("name", "考试地点");
|
|
|
+ basicMap1.put("value", "教学楼301");
|
|
|
+ basicPlate1.add(basicMap1);
|
|
|
+
|
|
|
+ basicMap1 = new HashMap<>();
|
|
|
+ basicMap1.put("code", "examCount");
|
|
|
+ basicMap1.put("name", "应考人数");
|
|
|
+ basicMap1.put("value", "61");
|
|
|
+ basicPlate1.add(basicMap1);
|
|
|
+
|
|
|
+ pdfPackageDto.setBasicPlate(basicPlate1);
|
|
|
+
|
|
|
+ try {
|
|
|
+ CreatePrintPdfUtil createPrintPdfUtil = new CreatePrintPdfUtil();
|
|
|
+ createPrintPdfUtil.createSignPdf(null, pdfFillDto, "D:/sign.pdf", true);
|
|
|
+ createPrintPdfUtil.createPackagePdf(null, pdfPackageDto, "D:/package.pdf", true);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|