|
|
@@ -205,19 +205,41 @@ public class PdfUtil {
|
|
|
createPDFCell(tableFont, table, data.get("note").toString(), Element.ALIGN_LEFT, 5, 1);
|
|
|
createPDFCell(tableFont, table, "参会人员签字", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
dealEduImageCell((List<String>) data.get("signImage"), table, 4, 80, 30);
|
|
|
- document.add(table);
|
|
|
+// document.add(table);
|
|
|
|
|
|
//第二页
|
|
|
//按6份等分图片数组,一页只显示6张
|
|
|
- final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 6);
|
|
|
+// final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 2);
|
|
|
+// for (List<String> stringList : listList) {
|
|
|
+// PdfPTable innerTable = new PdfPTable(6);
|
|
|
+// createPDFCell(tableFont, innerTable, "图片附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+// //一行展示一张图片
|
|
|
+// dealEduImageCell(new ArrayList<>(stringList), innerTable, 2, 185, 200);
|
|
|
+//// document.newPage();
|
|
|
+// document.add(innerTable);
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+ document.add(table);
|
|
|
+ PdfPTable imageTable = new PdfPTable(6);
|
|
|
+ final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 2);
|
|
|
+ createPDFCell(tableFont, imageTable, "图片附件", Element.ALIGN_MIDDLE, 1, listList.size()==0?1:listList.size());
|
|
|
for (List<String> stringList : listList) {
|
|
|
- PdfPTable innerTable = new PdfPTable(6);
|
|
|
- createPDFCell(tableFont, innerTable, "图片附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ PdfPTable innerTable = new PdfPTable(5);
|
|
|
+ innerTable.setWidthPercentage(100F);
|
|
|
+// createPDFCell(tableFont, innerTable, "图片附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
//一行展示一张图片
|
|
|
- dealEduImageCell(new ArrayList<>(stringList), innerTable, 2, 185, 200);
|
|
|
- document.newPage();
|
|
|
- document.add(innerTable);
|
|
|
+ dealEduImageCell2(new ArrayList<>(stringList), innerTable, 2, 185, 190);
|
|
|
+// document.newPage();
|
|
|
+ final PdfPCell cell1 = new PdfPCell();
|
|
|
+ cell1.setNoWrap(false);
|
|
|
+ cell1.setColspan(5);
|
|
|
+ cell1.setRowspan(1);
|
|
|
+ cell1.addElement(innerTable);
|
|
|
+ imageTable.addCell(cell1);
|
|
|
+
|
|
|
}
|
|
|
+ document.add(imageTable);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -553,19 +575,39 @@ public class PdfUtil {
|
|
|
//参会人员签字
|
|
|
createPDFCell(tableFont, table, "参演人员", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
dealEduImageCell((List<String>) data.get("signImage"), table, 4, 80, 30);
|
|
|
- document.add(table);
|
|
|
+// document.add(table);
|
|
|
|
|
|
//第二页
|
|
|
//按6份等分图片数组,一页只显示6张
|
|
|
- final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 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);
|
|
|
+// //一行展示一张图片
|
|
|
+// dealEduImageCell(new ArrayList<>(stringList), innerTable, 2, 185, 200);
|
|
|
+// document.newPage();
|
|
|
+// document.add(innerTable);
|
|
|
+// }
|
|
|
+ document.add(table);
|
|
|
+ PdfPTable imageTable = new PdfPTable(6);
|
|
|
+ final List<List<String>> listList = ListUtil.split((List<String>) data.get("fileImage"), 2);
|
|
|
+ createPDFCell(tableFont, imageTable, "图片附件", Element.ALIGN_MIDDLE, 1, listList.size()==0?1:listList.size());
|
|
|
for (List<String> stringList : listList) {
|
|
|
- PdfPTable innerTable = new PdfPTable(6);
|
|
|
- createPDFCell(tableFont, innerTable, "图片附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
+ PdfPTable innerTable = new PdfPTable(5);
|
|
|
+ innerTable.setWidthPercentage(100F);
|
|
|
+// createPDFCell(tableFont, innerTable, "图片附件", Element.ALIGN_MIDDLE, 1, 1);
|
|
|
//一行展示一张图片
|
|
|
- dealEduImageCell(new ArrayList<>(stringList), innerTable, 2, 185, 200);
|
|
|
- document.newPage();
|
|
|
- document.add(innerTable);
|
|
|
+ dealEduImageCell2(new ArrayList<>(stringList), innerTable, 2, 185, 190);
|
|
|
+// document.newPage();
|
|
|
+ final PdfPCell cell1 = new PdfPCell();
|
|
|
+ cell1.setNoWrap(false);
|
|
|
+ cell1.setColspan(5);
|
|
|
+ cell1.setRowspan(1);
|
|
|
+ cell1.addElement(innerTable);
|
|
|
+ imageTable.addCell(cell1);
|
|
|
+
|
|
|
}
|
|
|
+ document.add(imageTable);
|
|
|
}
|
|
|
|
|
|
public static void dealEduImageCell(List<String> imageList, PdfPTable table, Integer imageNumsOfRow, Integer imageWith, Integer imageHigh) throws Exception {
|
|
|
@@ -605,6 +647,45 @@ public class PdfUtil {
|
|
|
table.addCell(outCell);
|
|
|
}
|
|
|
|
|
|
+ public static void dealEduImageCell2(List<String> imageList, PdfPTable table, Integer imageNumsOfRow, Integer imageWith, Integer imageHigh) throws Exception {
|
|
|
+ //签字区域
|
|
|
+ PdfPCell outCell = new PdfPCell();
|
|
|
+ outCell.setNoWrap(false);
|
|
|
+ outCell.setColspan(5);
|
|
|
+ // outCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT | Rectangle.BOTTOM);
|
|
|
+ final int imageAddNums = imageList.size() % imageNumsOfRow;
|
|
|
+ if (imageAddNums != 0) {
|
|
|
+ for (int i = 0; i < imageNumsOfRow - imageAddNums; i++) {
|
|
|
+ imageList.add("black.png");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PdfPTable imageInnerTable = new PdfPTable(imageNumsOfRow);
|
|
|
+
|
|
|
+ imageInnerTable.setSplitRows(true);
|
|
|
+ imageInnerTable.setSplitLate(false);
|
|
|
+ imageInnerTable.setWidthPercentage(100F);
|
|
|
+ for (String image : imageList) {
|
|
|
+ Image imageData = convertFileToByteArray(new File(image));
|
|
|
+ if (imageData != null) {
|
|
|
+ imageData.scaleAbsolute(imageWith, imageHigh);
|
|
|
+ }
|
|
|
+ PdfPCell innerCell = new PdfPCell(imageData);
|
|
|
+ innerCell.setNoWrap(false);
|
|
|
+ innerCell.setPaddingTop(4f);
|
|
|
+ innerCell.setPaddingLeft(4f);
|
|
|
+ innerCell.setPaddingRight(4f);
|
|
|
+ innerCell.setPaddingBottom(4f);
|
|
|
+
|
|
|
+ innerCell.setBorder(Rectangle.NO_BORDER);
|
|
|
+ innerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
|
|
|
+ innerCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
|
|
|
+ imageInnerTable.addCell(innerCell);
|
|
|
+ }
|
|
|
+ outCell.addElement(imageInnerTable);
|
|
|
+ outCell.setBorder(Rectangle.NO_BORDER);
|
|
|
+ table.addCell(outCell);
|
|
|
+ }
|
|
|
+
|
|
|
public static void dealImageCell(List<String> imageList, PdfPTable table, Integer imageNumsOfRow, Integer imageWith, Integer imageHigh, Integer cosSpan, Integer rowSpan) throws Exception {
|
|
|
//签字区域
|
|
|
PdfPCell outCell = new PdfPCell();
|