|
@@ -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();
|
|
|
}
|
|
|
}
|