Procházet zdrojové kódy

pdf预览电签位置更改

lvy před 2 měsíci
rodič
revize
1853210ecf

+ 21 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/utils/PdfAddimgUtil.java

@@ -15,6 +15,7 @@ import org.springblade.system.cache.ParamCache;
 
 import java.io.*;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
@@ -68,6 +69,23 @@ public class PdfAddimgUtil {
             }
         }
     }
+
+    public static void main(String[] args) throws Exception {
+        String pdfUrl = "C://upload///pdf//1701069578999693447.pdf";
+        String keyword = "1703655562291445760,1703655562417274880,1703655562333388800,1703655562459217920,1823610566992723968";
+        Map<Long, TextdictInfo> textMap = new HashMap<>();
+        textMap.put(1703655562291445760L, new TextdictInfo(){{
+            setPyzbx(0.0f);
+            setPyzbx(0.0f);
+            setType(2);
+        }});
+        textMap.put(1703655562417274880L,new TextdictInfo(){{
+            setPyzbx(0.0f);
+            setPyzbx(0.0f);
+            setType(6);
+        }});
+        pdfAddImgInfo(pdfUrl, keyword, textMap);
+    }
     public static void pdfAddImgInfoNew(String pdfUrl, String keyword, Map<Long, TextdictInfo> textMap ,String signImg) throws Exception {
         File pdfFile = new File(pdfUrl);
         byte[] pdfData = new byte[(int) pdfFile.length()];
@@ -140,6 +158,9 @@ public class PdfAddimgUtil {
             float newWidth = 75f; // 新的宽度
             float newHeight = image.getScaledHeight() * (newWidth / image.getScaledWidth()); // 根据宽度计算高度
             image.scaleAbsolute(newWidth, newHeight); // 设置图片的新尺寸
+        } else {
+            x = x - image.getScaledWidth() / 4;
+            y = y - image.getScaledHeight() / 4;
         }
         //调整图片尺寸
         image.setAbsolutePosition(x, y);