zhaowenxuan
2024-12-10 c6b71608579cf87386e3ad82e58150424797cdc1
ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java
@@ -221,6 +221,46 @@
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
            }else {
                PdfPCell cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase("检查所见:", textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
                cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase(tjPdfVO.getProResult(), textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
                cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase("结论:", textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
                cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase(tjPdfVO.getProResult(), textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
            }
        }
        return table;
@@ -313,13 +353,53 @@
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
            }else {
                PdfPCell cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase("检查所见:", textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
                cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase(tjPdfVO.getProResult(), textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
                cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase("结论:", textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
                cell = new PdfPCell();
                // 水平、垂直居中
                cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                cell.setHorizontalAlignment(Element.ALIGN_LEFT);
                cell.setPhrase(new Phrase(tjPdfVO.getProResult(), textFont));
                // 设置无边框
                cell.setBorder(Rectangle.NO_BORDER);
                cell.setColspan(3);
                table.addCell(cell);
            }
        }
        return table;
    }
    private static PdfPTable createTable(float[] widths) {
    public static PdfPTable createTable(float[] widths) {
        PdfPTable table = new PdfPTable(widths);
        try {
            // 设置表格大小
@@ -344,7 +424,7 @@
        return table;
    }
    private static PdfPCell createCell(String value, Font font) {
    public static PdfPCell createCell(String value, Font font) {
        PdfPCell cell = new PdfPCell();
        // 水平、垂直居中
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
@@ -359,4 +439,30 @@
        return cell;
    }
    /**
     *
     * @param value
     * @param font
     * @param boder Rectangle类的枚举
     * @param txtAlign Element类的枚举
     * @return
     */
    public static PdfPCell createCell(String value, Font font,int boder,int txtAlign,Float paddingTop,Float paddingBottom) {
        PdfPCell cell = new PdfPCell();
        // 水平、垂直居中
        cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
        cell.setHorizontalAlignment(txtAlign);
        cell.setPhrase(new Phrase(value, font));
        if (paddingTop != null)
            cell.setPaddingTop(paddingTop);
        if (paddingBottom != null)
            cell.setPaddingBottom(paddingBottom);
        // 设置无边框
        cell.setBorder(boder);
        // 设置高度
        //cell.setFixedHeight(20);
        return cell;
    }
}