From dba27f21bc05c999ace46fe15be6e4c824ed9104 Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期五, 13 十二月 2024 18:40:09 +0800
Subject: [PATCH] zjh202412013

---
 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