|
|
@@ -39,6 +39,8 @@ public class PdfUtil {
|
|
|
// 设置各列列宽
|
|
|
// table.setTotalWidth(new float[]{90, 100, 100, 120, 100, 100});
|
|
|
table.setSpacingBefore(16f);
|
|
|
+ table.setSplitRows(false);
|
|
|
+ table.setSplitLate(true);
|
|
|
ItextPdfTableVo itextPdfTableVo = new ItextPdfTableVo();
|
|
|
itextPdfTableVo.setDocument(document);
|
|
|
itextPdfTableVo.setWriter(writer);
|
|
|
@@ -185,7 +187,7 @@ public class PdfUtil {
|
|
|
signCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
table.addCell(signCell);
|
|
|
//图片填充
|
|
|
- final PdfPTable imageTable = getImage((List<String>) data.get("image"), 12);
|
|
|
+ final PdfPTable imageTable = getImage((List<String>) data.get("image"), 12,100,100,5);
|
|
|
final PdfPCell cell = new PdfPCell();
|
|
|
cell.setNoWrap(false);
|
|
|
cell.setPaddingLeft(8f);
|
|
|
@@ -296,7 +298,7 @@ public class PdfUtil {
|
|
|
noteCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
table.addCell(noteCell);
|
|
|
//演练情况 图片填充
|
|
|
- final PdfPTable imageTable1 = getImage((List<String>) data.get("imageData"), 6);
|
|
|
+ final PdfPTable imageTable1 = getImage((List<String>) data.get("imageData"), 6,100,100,3);
|
|
|
final PdfPCell cell1 = new PdfPCell();
|
|
|
cell1.setNoWrap(false);
|
|
|
cell1.setPaddingLeft(8f);
|
|
|
@@ -317,7 +319,7 @@ public class PdfUtil {
|
|
|
signCell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
|
|
|
table.addCell(signCell);
|
|
|
//图片填充
|
|
|
- final PdfPTable imageTable = getImage((List<String>) data.get("image"), 6);
|
|
|
+ final PdfPTable imageTable = getImage((List<String>) data.get("image"), 12,50,50,5);
|
|
|
final PdfPCell cell = new PdfPCell();
|
|
|
cell.setNoWrap(false);
|
|
|
cell.setPaddingLeft(8f);
|
|
|
@@ -341,11 +343,13 @@ public class PdfUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- private static PdfPTable getImage(List<String> images, int totalImages) 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<>();
|
|
|
}
|
|
|
- PdfPTable innerTable = new PdfPTable(3);
|
|
|
+ PdfPTable innerTable = new PdfPTable(ImageNumsOfRow);
|
|
|
+ innerTable.setSplitRows(false);
|
|
|
+ innerTable.setSplitLate(true);
|
|
|
//这里根据实际图片数量来判断是否需要补充白色图片,保证每行显示3张图片,用以填充空白
|
|
|
final int reallySize = images.size();
|
|
|
List<String> list = new ArrayList<>(images);
|
|
|
@@ -354,8 +358,8 @@ public class PdfUtil {
|
|
|
}
|
|
|
//分割,每行显示3张图片,获取分割的行数
|
|
|
List<List<String>> rows = new ArrayList<>();
|
|
|
- for (int i = 0; i < list.size(); i += 3) {
|
|
|
- List<String> row = list.subList(i, Math.min(i + 3, list.size()));
|
|
|
+ for (int i = 0; i < list.size(); i += ImageNumsOfRow) {
|
|
|
+ List<String> row = list.subList(i, Math.min(i + ImageNumsOfRow, list.size()));
|
|
|
rows.add(row);
|
|
|
}
|
|
|
|
|
|
@@ -365,7 +369,7 @@ public class PdfUtil {
|
|
|
Image imageData = null;
|
|
|
imageData = convertFileToByteArray(new File(image));
|
|
|
if(imageData != null ){
|
|
|
- imageData.scaleAbsolute(100, 100);
|
|
|
+ imageData.scaleAbsolute(imageWidth, imageHeight);
|
|
|
}
|
|
|
PdfPCell cell = new PdfPCell(imageData);
|
|
|
cell.setBorder(Rectangle.NO_BORDER);
|
|
|
@@ -386,6 +390,8 @@ public class PdfUtil {
|
|
|
PdfPTable outerTable = new PdfPTable(1);
|
|
|
PdfPCell innerCell = new PdfPCell(innerTable);
|
|
|
innerCell.setBorder(Rectangle.NO_BORDER);
|
|
|
+ outerTable.setSplitRows(false);
|
|
|
+ outerTable.setSplitLate(true);
|
|
|
outerTable.addCell(innerCell);
|
|
|
return outerTable;
|
|
|
}
|