|
|
@@ -325,104 +325,53 @@ public class PdfUtil {
|
|
|
}
|
|
|
|
|
|
public static void dealDrillBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
|
|
|
- table.setSplitLate(false);
|
|
|
- table.setSplitRows(true);
|
|
|
//第一行
|
|
|
createPDFCell(tableFont, table, "演练单位", Element.ALIGN_CENTER, 1, 1);
|
|
|
createPDFCell(tableFont, table, data.get("orgName").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
createPDFCell(tableFont, table, "地点", Element.ALIGN_CENTER, 1, 1);
|
|
|
createPDFCell(tableFont, table, data.get("drillSite").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
//第二行
|
|
|
- createPDFCell(tableFont, table, "演练时间", Element.ALIGN_CENTER, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("drillTime").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
- createPDFCell(tableFont, table, "演练项目", Element.ALIGN_CENTER, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("typeText").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
- //第三行
|
|
|
createPDFCell(tableFont, table, "指挥人", Element.ALIGN_CENTER, 1, 1);
|
|
|
createPDFCell(tableFont, table, data.get("hostName").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
createPDFCell(tableFont, table, "记录人", Element.ALIGN_CENTER, 1, 1);
|
|
|
createPDFCell(tableFont, table, data.get("recorderName").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
-
|
|
|
+ //第三行
|
|
|
+ createPDFCell(tableFont, table, "演练时间", Element.ALIGN_CENTER, 1, 1);
|
|
|
+ createPDFCell(tableFont, table, data.get("drillTime").toString(), Element.ALIGN_LEFT, 5, 1);
|
|
|
+ createPDFCell(tableFont, table, "演练项目", Element.ALIGN_CENTER, 1, 1);
|
|
|
+ createPDFCell(tableFont, table, data.get("typeText").toString(), Element.ALIGN_LEFT, 5, 1);
|
|
|
//预设案由
|
|
|
- PdfPCell contentCell = new PdfPCell();
|
|
|
- contentCell.setColspan(6);
|
|
|
- final Paragraph presetCase = new Paragraph(new Chunk(data.get("presetCase").toString(), tableFont));
|
|
|
- presetCase.setSpacingAfter(8F);
|
|
|
- contentCell.addElement(presetCase);
|
|
|
- contentCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- table.addCell(contentCell);
|
|
|
- dealDrillImageCell(data.get("drillSituation").toString(), tableFont, (List<String>) data.get("imageData"), table);
|
|
|
- dealDrillImageCell("参会演练人员(签字):", tableFont, (List<String>) data.get("image"), table);
|
|
|
- /* //演练情况
|
|
|
- PdfPCell noteCell = new PdfPCell();
|
|
|
- noteCell.setColspan(6);
|
|
|
- Paragraph noteParagraph = new Paragraph(new Chunk(data.get("drillSituation").toString(), tableFont));
|
|
|
- noteParagraph.setSpacingAfter(8F);
|
|
|
- noteCell.addElement(noteParagraph);
|
|
|
- noteCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- final List<String> imageDataList = (List<String>) data.get("imageData");
|
|
|
- final int imageDataAddNums = imageDataList.size() % 3;
|
|
|
- for (int i = 0; i < 3 - imageDataAddNums; i++) {
|
|
|
- imageDataList.add("black.png");
|
|
|
- }
|
|
|
- PdfPTable imageDataInnerTable = new PdfPTable(3);
|
|
|
- for (String str : imageDataList) {
|
|
|
- Image imageData = convertFileToByteArray(new File(str));
|
|
|
- if (imageData != null) {
|
|
|
- imageData.scaleAbsolute(130, 130);
|
|
|
- }
|
|
|
- PdfPCell cell = new PdfPCell(imageData);
|
|
|
- cell.setBorder(Rectangle.NO_BORDER);
|
|
|
- cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
- cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
- imageDataInnerTable.addCell(cell);
|
|
|
- }
|
|
|
- noteCell.addElement(imageDataInnerTable);
|
|
|
- table.addCell(noteCell);
|
|
|
-
|
|
|
- //签字区域
|
|
|
- PdfPCell signCell = new PdfPCell();
|
|
|
- signCell.setColspan(6);
|
|
|
- final Paragraph paragraph1 = new Paragraph(new Chunk("参会演练人员(签字):", tableFont));
|
|
|
- paragraph1.setSpacingAfter(8F);
|
|
|
- signCell.addElement(paragraph1);
|
|
|
- signCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
- final List<String> imageList = (List<String>) data.get("image");
|
|
|
- final int imageAddNums = imageList.size() % 3;
|
|
|
- for (int i = 0; i < 3 - imageAddNums; i++) {
|
|
|
- imageList.add("black.png");
|
|
|
- }
|
|
|
- PdfPTable imageInnerTable = new PdfPTable(3);
|
|
|
- for (String str : imageList) {
|
|
|
- Image imageData = convertFileToByteArray(new File(str));
|
|
|
- if (imageData != null) {
|
|
|
- imageData.scaleAbsolute(130, 130);
|
|
|
- }
|
|
|
- PdfPCell cell = new PdfPCell(imageData);
|
|
|
- cell.setBorder(Rectangle.NO_BORDER);
|
|
|
- cell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
- cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
- imageInnerTable.addCell(cell);
|
|
|
- }
|
|
|
- signCell.addElement(imageInnerTable);
|
|
|
- table.addCell(signCell);*/
|
|
|
-
|
|
|
-
|
|
|
+ createPDFCell(tableFont, table, "预设案由", Element.ALIGN_MIDDLE, 1, 140);
|
|
|
+ createPDFCell(tableFont, table, data.get("presetCase").toString(), Element.ALIGN_LEFT, 5, 140);
|
|
|
+ //演练情况
|
|
|
+ createPDFCell(tableFont, table, "演练情况", Element.ALIGN_MIDDLE, 1, 140);
|
|
|
+ createPDFCell(tableFont, table, data.get("drillSituation").toString(), Element.ALIGN_LEFT, 5, 140);
|
|
|
//点评总结
|
|
|
- PdfPCell commentCell = new PdfPCell();
|
|
|
- commentCell.setColspan(6);
|
|
|
- commentCell.addElement(new Paragraph(new Chunk(data.get("comment").toString(), tableFont)));
|
|
|
- table.addCell(commentCell);
|
|
|
+ createPDFCell(tableFont, table, "点评总结", Element.ALIGN_MIDDLE, 1, 140);
|
|
|
+ createPDFCell(tableFont, table, data.get("comment").toString(), Element.ALIGN_LEFT, 5, 140);
|
|
|
+ //参会人员签字
|
|
|
+ createPDFCell(tableFont, table, "参会人员签字", Element.ALIGN_MIDDLE, 1, 140);
|
|
|
+ dealEduImageCell((List<String>) data.get("signImage"), table, 5, 30, 30);
|
|
|
document.add(table);
|
|
|
+
|
|
|
+ //第二页
|
|
|
+ //按6份等分图片数组,一页只显示6张
|
|
|
+ final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 6);
|
|
|
+ for (List<String> stringList : listList) {
|
|
|
+ PdfPTable innerTable = new PdfPTable(6);
|
|
|
+ createPDFCell(tableFont, innerTable, "图片附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ innerTable.setSpacingBefore(10f);
|
|
|
+ //一行展示一张图片
|
|
|
+ dealEduImageCell(new ArrayList<>(stringList), innerTable, 2, 150, 200);
|
|
|
+ document.newPage();
|
|
|
+ document.add(innerTable);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public static void dealDrillImageCell(String chunk, Font tableFont, List<String> imageList, PdfPTable table) throws Exception {
|
|
|
+ public static void dealDrillImageCell( List<String> imageList, PdfPTable table) throws Exception {
|
|
|
//签字区域
|
|
|
PdfPCell outCell = new PdfPCell();
|
|
|
- outCell.setColspan(6);
|
|
|
- final Paragraph paragraph1 = new Paragraph(new Chunk(chunk, tableFont));
|
|
|
- paragraph1.setSpacingAfter(8F);
|
|
|
- outCell.addElement(paragraph1);
|
|
|
+ outCell.setColspan(5);
|
|
|
outCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
final int imageAddNums = imageList.size() % 3;
|
|
|
if (imageAddNums != 0) {
|