Browse Source

修改tools-common,重命名PageSize为PaperSize

Signed-off-by: luoshi <luoshi@qmth.com.cn>
luoshi 2 năm trước cách đây
mục cha
commit
087089d97f

+ 7 - 7
tools-common/src/main/java/com/qmth/boot/tools/html2pdf/HtmlToPdf.java

@@ -1,6 +1,6 @@
 package com.qmth.boot.tools.html2pdf;
 
-import com.qmth.boot.tools.models.PageSize;
+import com.qmth.boot.tools.models.PaperSize;
 import org.apache.commons.lang3.StringUtils;
 
 import java.io.File;
@@ -44,12 +44,12 @@ public class HtmlToPdf {
     /**
      * 执行html转pdf操作
      *
-     * @param url      - html的完整链接地址
-     * @param file     - 本地生成文件,自动创建所在目录,不存在时自动创建空白文件
-     * @param pageSize - 转换纸张尺寸
+     * @param url       - html的完整链接地址
+     * @param file      - 本地生成文件,自动创建所在目录,不存在时自动创建空白文件
+     * @param paperSize - 转换纸张尺寸
      * @throws Exception
      */
-    public static void execute(String url, File file, PageSize pageSize) throws Exception {
+    public static void execute(String url, File file, PaperSize paperSize) throws Exception {
         if (exePath == null) {
             throw new RuntimeException("HtmlToPdf exePath unexists");
         }
@@ -58,11 +58,11 @@ public class HtmlToPdf {
             file.createNewFile();
         }
         String extendParam = "";
-        if (pageSize == PageSize.A3) {
+        if (paperSize == PaperSize.A3) {
             extendParam = "--orientation Landscape";
         }
         String command = String
-                .format(COMMAND_PATTERN, exePath, pageSize.getCode(), extendParam, url, file.getAbsolutePath());
+                .format(COMMAND_PATTERN, exePath, paperSize.getCode(), extendParam, url, file.getAbsolutePath());
         Runtime.getRuntime().exec(command).waitFor();
     }
 }

+ 4 - 4
tools-common/src/main/java/com/qmth/boot/tools/models/PageSize.java → tools-common/src/main/java/com/qmth/boot/tools/models/PaperSize.java

@@ -3,7 +3,7 @@ package com.qmth.boot.tools.models;
 /**
  * 通用纸张大小
  */
-public enum PageSize {
+public enum PaperSize {
 
     A3("A3", 420, 297),
     A4("A4", 210, 297),
@@ -18,7 +18,7 @@ public enum PageSize {
 
     private int height;
 
-    PageSize(String code, int width, int height) {
+    PaperSize(String code, int width, int height) {
         this.code = code;
         this.width = width;
         this.height = height;
@@ -36,8 +36,8 @@ public enum PageSize {
         return height;
     }
 
-    public static PageSize findByCode(String code) {
-        for (PageSize ps : PageSize.values()) {
+    public static PaperSize findByCode(String code) {
+        for (PaperSize ps : PaperSize.values()) {
             if (ps.getCode().equalsIgnoreCase(code)) {
                 return ps;
             }