From ae15dc64b21b6ed3a96a5945f2f1ce1bc8833a3f Mon Sep 17 00:00:00 2001 From: zhaowenxuan <chacca165@163.com> Date: 星期五, 13 十二月 2024 20:20:25 +0800 Subject: [PATCH] 20241213 --- ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java | 35 +++++++++++++++++++++++++++++++---- 1 files changed, 31 insertions(+), 4 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java b/ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java index 2626476..824b161 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/config/pdfutils/PdfUtils.java @@ -261,9 +261,10 @@ * @param list * @return */ - public static PdfPTable setTable2(Font headFont, Font textFont, String[] title, List<TjPdfVO> list,boolean flag) { + public static PdfPTable setTable2(Font headFont, Font textFont, String[] title, List<TjPdfVO> list,boolean flag,float[] titleWidth) { //鍥涘垪 - PdfPTable table = createTable(new float[]{240, 240,240}); + PdfPTable table = createTable(titleWidth); +// PdfPTable table = createTable(new float[]{240, 240,240}); //鐢绘爣棰� for (String head : title) { table.addCell(createCell(head, headFont)); @@ -319,7 +320,7 @@ } - private static PdfPTable createTable(float[] widths) { + public static PdfPTable createTable(float[] widths) { PdfPTable table = new PdfPTable(widths); try { // 璁剧疆琛ㄦ牸澶у皬 @@ -344,7 +345,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 +360,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; + } } -- Gitblit v1.8.0