|
|
@@ -183,7 +183,7 @@ public class PdfUtil {
|
|
|
signCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
table.addCell(signCell);
|
|
|
//图片填充
|
|
|
- final PdfPTable imageTable = getImage((List<String>) data.get("image"), 12,100,100,3);
|
|
|
+ final PdfPTable imageTable = getImage((List<String>) data.get("image"), 12, 100, 100, 3);
|
|
|
final PdfPCell cell = new PdfPCell();
|
|
|
cell.setNoWrap(false);
|
|
|
cell.setPaddingLeft(8f);
|
|
|
@@ -288,7 +288,7 @@ public class PdfUtil {
|
|
|
//证件图片
|
|
|
createPDFCell(tableFont, table, "证件图片", Element.ALIGN_CENTER, 1, 70);
|
|
|
//演练情况 图片填充
|
|
|
- final PdfPTable imageTable1 = getImage((List<String>) data.get("imageFile"), 4,150,130,2);
|
|
|
+ final PdfPTable imageTable1 = getImage((List<String>) data.get("imageFile"), 4, 150, 130, 2);
|
|
|
final PdfPCell cell1 = new PdfPCell();
|
|
|
cell1.setNoWrap(false);
|
|
|
cell1.setPaddingLeft(8f);
|
|
|
@@ -301,7 +301,7 @@ public class PdfUtil {
|
|
|
cell1.addElement(imageTable1);
|
|
|
table.addCell(cell1);
|
|
|
createPDFCell(tableFont, table, "介绍信附件", Element.ALIGN_CENTER, 1, 70);
|
|
|
- final PdfPTable imageTable2 = getImage((List<String>) data.get("file"), 2,150,150,2);
|
|
|
+ final PdfPTable imageTable2 = getImage((List<String>) data.get("file"), 2, 150, 150, 2);
|
|
|
final PdfPCell cell2 = new PdfPCell();
|
|
|
cell2.setNoWrap(false);
|
|
|
cell2.setPaddingLeft(8f);
|
|
|
@@ -314,7 +314,7 @@ public class PdfUtil {
|
|
|
cell2.addElement(imageTable2);
|
|
|
table.addCell(cell2);
|
|
|
createPDFCell(tableFont, table, "身份核验材料", Element.ALIGN_CENTER, 1, 70);
|
|
|
- final PdfPTable imageTable3 = getImage((List<String>) data.get("checkImage"), 2,150,150,2);
|
|
|
+ final PdfPTable imageTable3 = getImage((List<String>) data.get("checkImage"), 2, 150, 150, 2);
|
|
|
final PdfPCell cell3 = new PdfPCell();
|
|
|
cell3.setNoWrap(false);
|
|
|
cell3.setPaddingLeft(8f);
|
|
|
@@ -330,6 +330,7 @@ public class PdfUtil {
|
|
|
|
|
|
document.add(table);
|
|
|
}
|
|
|
+
|
|
|
public static void dealDrillBody(Document document, PdfPTable table, Font tableFont, Map<String, Object> data) throws Exception {
|
|
|
table.setSplitLate(false);
|
|
|
table.setSplitRows(true);
|
|
|
@@ -341,13 +342,15 @@ public class PdfUtil {
|
|
|
//第二行
|
|
|
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("typeText").toString(), Element.ALIGN_CENTER, 5, 1);
|
|
|
-
|
|
|
+ createPDFCell(tableFont, table, "记录人", Element.ALIGN_CENTER, 1, 1);
|
|
|
+ createPDFCell(tableFont, table, data.get("recorderName").toString(), Element.ALIGN_CENTER, 2, 1);
|
|
|
//预设案由
|
|
|
PdfPCell contentCell = new PdfPCell();
|
|
|
contentCell.setColspan(6);
|
|
|
@@ -356,67 +359,71 @@ public class PdfUtil {
|
|
|
contentCell.addElement(presetCase);
|
|
|
contentCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
table.addCell(contentCell);
|
|
|
-
|
|
|
//演练情况
|
|
|
PdfPCell noteCell = new PdfPCell();
|
|
|
noteCell.setColspan(6);
|
|
|
- Paragraph paragraph = new Paragraph(new Chunk(data.get("drillSituation").toString(), tableFont));
|
|
|
- paragraph.setSpacingAfter(8F);
|
|
|
- noteCell.addElement(paragraph);
|
|
|
- noteCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
+ 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);
|
|
|
- //演练情况 图片填充
|
|
|
- final PdfPTable imageTable1 = getImage((List<String>) data.get("imageData"), 6,100,100,3);
|
|
|
- final PdfPCell cell1 = new PdfPCell();
|
|
|
- cell1.setNoWrap(false);
|
|
|
- cell1.setPaddingLeft(8f);
|
|
|
- cell1.setPaddingRight(8f);
|
|
|
- cell1.setPaddingBottom(8f);
|
|
|
- cell1.setPaddingTop(8f);
|
|
|
- cell1.setColspan(6);
|
|
|
- cell1.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- cell1.addElement(imageTable1);
|
|
|
- table.addCell(cell1);
|
|
|
|
|
|
//签字区域
|
|
|
PdfPCell signCell = new PdfPCell();
|
|
|
signCell.setColspan(6);
|
|
|
- Paragraph signParagraph = new Paragraph(new Chunk("参会演练人员(签字):", tableFont));
|
|
|
- signParagraph.setSpacingAfter(8F);
|
|
|
- signCell.addElement(signParagraph);
|
|
|
+ final Paragraph paragraph1 = new Paragraph(new Chunk("参会演练人员(签字):", tableFont));
|
|
|
+ paragraph1.setSpacingAfter(8F);
|
|
|
+ signCell.addElement(paragraph1);
|
|
|
signCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
- //table.addCell(signCell);
|
|
|
- //签字区域-图片填充
|
|
|
- final PdfPTable imageTable = getImage((List<String>) data.get("image"), 12,100,100,3);
|
|
|
- final PdfPCell cell = new PdfPCell();
|
|
|
- cell.setNoWrap(false);
|
|
|
- cell.setPaddingLeft(8f);
|
|
|
- cell.setPaddingRight(8f);
|
|
|
- cell.setPaddingBottom(8f);
|
|
|
- cell.setPaddingTop(8f);
|
|
|
- cell.setColspan(6);
|
|
|
- cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
- // cell.addElement(imageTable);
|
|
|
- signCell.addElement(imageTable);
|
|
|
+ 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);
|
|
|
+
|
|
|
+
|
|
|
//点评总结
|
|
|
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_CENTER, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("recorderName").toString(), Element.ALIGN_CENTER, 5, 1);
|
|
|
-
|
|
|
- /* //第三行
|
|
|
- createPDFCell(tableFont, table, "参会人员签字", Element.ALIGN_CENTER, 1, 1);
|
|
|
- createPDFCell(tableFont, table, data.get("users").toString(), Element.ALIGN_CENTER, 5, 1);*/
|
|
|
-
|
|
|
document.add(table);
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static PdfPTable getImage(List<String> images, int totalImages,float imageWidth, float imageHeight,Integer ImageNumsOfRow) throws Exception {
|
|
|
+ private static PdfPTable getImage(List<String> images, int totalImages, float imageWidth, float imageHeight, Integer ImageNumsOfRow) throws Exception {
|
|
|
if (images == null) {
|
|
|
images = new ArrayList<>();
|
|
|
}
|
|
|
@@ -441,7 +448,7 @@ public class PdfUtil {
|
|
|
for (String image : row) {
|
|
|
Image imageData = null;
|
|
|
imageData = convertFileToByteArray(new File(image));
|
|
|
- if(imageData != null ){
|
|
|
+ if (imageData != null) {
|
|
|
imageData.scaleAbsolute(imageWidth, imageHeight);
|
|
|
}
|
|
|
PdfPCell cell = new PdfPCell(imageData);
|