Parcourir la source

Merge branch 'branch-nt-1.0.1' of https://git.flowbb.cn/RK-Dev/fqgz-server into branch-nt-1.0.1

humuyu il y a 3 ans
Parent
commit
a36dc03ec9

+ 8 - 0
eladmin-system/src/main/java/me/zhengjie/base/util/HtmlConvertToPdf.java

@@ -10,6 +10,8 @@ import org.jsoup.nodes.Document;
 import org.springframework.beans.factory.InitializingBean;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 import org.zefer.pd4ml.PD4Constants;
 import org.zefer.pd4ml.PD4ML;
 
@@ -113,6 +115,12 @@ public class HtmlConvertToPdf implements InitializingBean {
 		builder.withUri(destPath);
 		builder.toStream(os);
 		builder.withW3cDocument(new W3CDom().fromJsoup(document), baseUri);
+		builder.addDOMMutator(doc -> {
+			Element style = doc.createElement("style");
+			Node node = doc.createTextNode("@page { margin-top: 90px; margin-bottom: 90px; }");
+			style.appendChild(node);
+			doc.getElementsByTagName("head").item(0).appendChild(style);
+		});
 
 		//引入指定字体,注意字体名需要和css样式中指定的字体名相同
 		String fontPath = HtmlConvertToPdf.class.getClassLoader().getResource("").getPath();

+ 1 - 1
eladmin-system/src/main/resources/config/application.yml

@@ -71,4 +71,4 @@ fqgz:
 html2Pdf:
   simsumPath: font/simsun.ttf
   simfangPath: font/simfang.ttf
-  toolName: PD4ML
+  toolName: OpenPDF