zjh
2024-09-05 9155df2aeab5b0d95c89dd928dbaefbfbaeae9d1
ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java
@@ -25,6 +25,7 @@
     * 字体存放的跟路径,默认为'C:\Windows\Fonts\'
     */
    private static final String FONT_PATH = "C:\\Windows\\Fonts\\";
//    private static final String FONT_PATH = "/Users/chacca/开发相关/代码/ltkj_peis/ltkj-admin/src/main/resources/Font/";
    /**
     * 纸张大小
@@ -38,7 +39,7 @@
     * @throws DocumentException
     * @throws IOException
     */
    private static BaseFont createBaseFont(String fontName) throws DocumentException, IOException {
    public static BaseFont createBaseFont(String fontName) throws DocumentException, IOException {
        // 默认为宋体
        if (fontName == null) {
            fontName = "simsun.ttc";
@@ -151,7 +152,7 @@
     */
    public static PdfPTable setTable(Font headFont, Font textFont, String[] title, List<TjPdfVO> list) {
        //四列
        PdfPTable table = createTable(new float[]{120, 120, 120, 120});
        PdfPTable table = createTable(new float[]{120, 120, 120});
        //画标题
        for (String head : title) {
            table.addCell(createCell(head, headFont));
@@ -161,7 +162,7 @@
            table.addCell(createCell(tjPdfVO.getProName(), textFont));
            table.addCell(createCell(tjPdfVO.getProResult(), textFont));
            table.addCell(createCell(tjPdfVO.getCompany(), textFont));
            table.addCell(createCell(tjPdfVO.getStandardValue(), textFont));
//            table.addCell(createCell(tjPdfVO.getStandardValue(), textFont));
        }
        return table;
    }
@@ -191,6 +192,33 @@
        return table;
    }
    /**
     * 设置
     * 表格内容
     *
     * @param headFont
     * @param textFont
     * @param title
     * @param list
     * @return
     */
    public static PdfPTable setTable2(Font headFont, Font textFont, String[] title, List<TjPdfVO> list) {
        //四列
        PdfPTable table = createTable(new float[]{240, 240,240});
        //画标题
        for (String head : title) {
            table.addCell(createCell(head, headFont));
        }
        //画内容
        for (TjPdfVO tjPdfVO : list) {
            table.addCell(createCell(tjPdfVO.getProName(), textFont));
            table.addCell(createCell(tjPdfVO.getProResult(), textFont));
            table.addCell(createCell(tjPdfVO.getCompany(), textFont));
        }
        return table;
    }
    private static PdfPTable createTable(float[] widths) {
        PdfPTable table = new PdfPTable(widths);
        try {