|
|
@@ -15,6 +15,9 @@ import com.itextpdf.text.pdf.PdfWriter;
|
|
|
import org.apache.poi.ss.usermodel.*;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.apache.poi.xwpf.usermodel.*;
|
|
|
+import org.docx4j.Docx4J;
|
|
|
+import org.docx4j.openpackaging.exceptions.Docx4JException;
|
|
|
+import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
|
|
|
import org.springframework.http.MediaType;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
@@ -376,6 +379,18 @@ public class PDFUtils {
|
|
|
return font;
|
|
|
}
|
|
|
|
|
|
+ public static void newConvertWordToPDF(String s, String s1) {
|
|
|
+ try (FileOutputStream fos = new FileOutputStream(s1)) {
|
|
|
+ WordprocessingMLPackage wordMLPackage = Docx4J.load(new File(s));
|
|
|
+ Docx4J.toPDF(wordMLPackage, fos);
|
|
|
+ } catch (Docx4JException e) {
|
|
|
+ throw new RuntimeException("转换Word文档到PDF失败: " + s, e);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ throw new RuntimeException("找不到文件: " + s + " 或 " + s1, e);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException("写入PDF文件时发生IO错误: " + s1, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
public void pushRd(OutWordRdDetails data, HttpServletResponse response,String uploadPath) {
|