Commit 6a7130f1 authored by hongguangwu's avatar hongguangwu

MVP1.7.11-是否自动生成解除劳动合同书 0否1是

parent f0a54cb9
...@@ -106,13 +106,13 @@ public class WordToImageUtil { ...@@ -106,13 +106,13 @@ public class WordToImageUtil {
} }
// 在生产环境中,建议在整个应用生命周期中共享一个OfficeManager: // 在生产环境中,建议在整个应用生命周期中共享一个OfficeManager:
public static OfficeManager OFFICE_MANAGER; public OfficeManager officeManager;
static { public void initOfficeManager() {
OFFICE_MANAGER = LocalOfficeManager.builder() this.officeManager = LocalOfficeManager.builder()
.portNumbers(2003) .portNumbers(2003)
.build(); .build();
try { try {
OFFICE_MANAGER.start(); officeManager.start();
} catch (OfficeException e) { } catch (OfficeException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -124,13 +124,14 @@ public class WordToImageUtil { ...@@ -124,13 +124,14 @@ public class WordToImageUtil {
File pdfFile = null; File pdfFile = null;
File imgFile = null; File imgFile = null;
try { try {
initOfficeManager();
// Step 1: Word 转为 PDF(中间格式) // Step 1: Word 转为 PDF(中间格式)
pdfFile = new File(inputDocx.replace(".docx", ".pdf")); pdfFile = new File(inputDocx.replace(".docx", ".pdf"));
Map<String, Object> pdfProps = new HashMap<>(); Map<String, Object> pdfProps = new HashMap<>();
pdfProps.put("FilterName", "writer_pdf_Export"); pdfProps.put("FilterName", "writer_pdf_Export");
pdfProps.put("SelectPdfVersion", 1); // PDF/A-1 pdfProps.put("SelectPdfVersion", 1); // PDF/A-1
LocalConverter.builder() LocalConverter.builder()
.officeManager(OFFICE_MANAGER) .officeManager(officeManager)
.storeProperties(pdfProps) .storeProperties(pdfProps)
.build() .build()
.convert(new File(inputDocx)) .convert(new File(inputDocx))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment