|
|
@@ -3,6 +3,7 @@ package me.zhengjie.base.util;
|
|
|
import com.openhtmltopdf.outputdevice.helper.BaseRendererBuilder;
|
|
|
import com.openhtmltopdf.pdfboxout.PdfRendererBuilder;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import me.zhengjie.utils.FileUtil;
|
|
|
import org.apache.commons.io.FileUtils;
|
|
|
import org.jsoup.Jsoup;
|
|
|
import org.jsoup.helper.W3CDom;
|
|
|
@@ -130,4 +131,23 @@ public class HtmlConvertToPdf implements InitializingBean {
|
|
|
|
|
|
builder.run();
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ try {
|
|
|
+ HtmlConvertToPdf htmlConvertToPdf = new HtmlConvertToPdf();
|
|
|
+ htmlConvertToPdf.setSimsumPath("/font/simsun.ttf");
|
|
|
+ htmlConvertToPdf.setSimfangPath("/font/simfang.ttf");
|
|
|
+ htmlConvertToPdf.convertPdfWithOpenPDF(FileUtil.readUtf8String("/Users/sakuya/Downloads/9e88124747724a17996afeda61dbb758.html"), "/Users/sakuya/Downloads/a44a021e9a0d473092fd051c48b3d36b.pdf");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSimsumPath(String simsumPath){
|
|
|
+ this.simsumPath=simsumPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSimfangPath(String simfangPath){
|
|
|
+ this.simfangPath =simfangPath;
|
|
|
+ }
|
|
|
}
|