From ff8914dab90da51dc8d46010f4f658780d5dba0e Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期一, 14 四月 2025 17:27:43 +0800
Subject: [PATCH] zjh20250414

---
 ltkj-common/src/main/java/com/ltkj/common/utils/PDFDocumentUtil.java |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/ltkj-common/src/main/java/com/ltkj/common/utils/PDFDocumentUtil.java b/ltkj-common/src/main/java/com/ltkj/common/utils/PDFDocumentUtil.java
index ee3d5a4..1f09a33 100644
--- a/ltkj-common/src/main/java/com/ltkj/common/utils/PDFDocumentUtil.java
+++ b/ltkj-common/src/main/java/com/ltkj/common/utils/PDFDocumentUtil.java
@@ -7,9 +7,11 @@
 import com.google.zxing.common.BitMatrix;
 import com.itextpdf.text.*;
 import com.itextpdf.text.pdf.*;
+import org.apache.commons.codec.binary.Base64;
 
 import javax.imageio.ImageIO;
 import java.awt.image.BufferedImage;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.util.HashMap;
@@ -93,7 +95,7 @@
                         map.put(EncodeHintType.CHARACTER_SET,"utf-8");
                         BitMatrix encode = null;
                         try {
-                            encode = new MultiFormatWriter().encode(tjNumber, BarcodeFormat.CODE_128, 300, 100, map);
+                            encode = new MultiFormatWriter().encode(tjNumber, BarcodeFormat.CODE_128, 500, 100, map);
                         } catch (WriterException e) {
                             e.printStackTrace();
                         }
@@ -241,7 +243,7 @@
      * @throws DocumentException
      * @throws IOException
      */
-    public static void makeTjInfo(Document document,List<Map<String ,String>> data) throws DocumentException, IOException {
+    public static void makeTjInfo(Document document,List<Map<String ,Object>> data) throws DocumentException, IOException {
         PdfPTable table1 = new PdfPTable(7);
         table1.setWidthPercentage(100);
         float[] columnWidths = {1.5f, 3, 3, 6, 1.5f, 3, 3};
@@ -294,4 +296,29 @@
         document.close();
         return (ByteArrayOutputStream) map.get("stream");
     }
+
+    /**
+     * 灏嗗涓猙ase64pdf鍚堝苟涓轰竴涓�
+     * @param base64PdfList pdf闆嗗悎
+     * @return
+     */
+    public static byte[] mergePDFs(List<String > base64PdfList) throws DocumentException, IOException {
+        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+        Document document = new Document();
+        PdfCopy copy = new PdfCopy(document, byteArrayOutputStream);
+        document.open();
+        for (String base64Pdf : base64PdfList) {
+            byte[] pdfBytes = Base64.decodeBase64(base64Pdf);
+            PdfReader reader = new PdfReader(new ByteArrayInputStream(pdfBytes));
+            int numberOfPages = reader.getNumberOfPages();
+            for (int i = 1; i <= numberOfPages; i++) {
+                document.newPage();
+                PdfImportedPage page = copy.getImportedPage(reader, i);
+                copy.addPage(page);
+            }
+            reader.close();
+        }
+        document.close();
+        return byteArrayOutputStream.toByteArray();
+    }
 }

--
Gitblit v1.8.0