|
|
@@ -1,6 +1,6 @@
|
|
|
package com.siwei.apply.utils;
|
|
|
|
|
|
-//import com.aspose.words.*;
|
|
|
+import com.aspose.words.*;
|
|
|
import com.siwei.common.core.utils.StringUtils;
|
|
|
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
import org.apache.poi.util.Units;
|
|
|
@@ -499,29 +499,29 @@ public class NpoiHelper {
|
|
|
FileOutputStream os = null;
|
|
|
try {
|
|
|
//取用户字体目录
|
|
|
-// String userfontsfoloder = System.getProperty("user.home") + "\\Microsoft\\Windows\\Fonts\\";
|
|
|
-// System.out.println("userfontsfoloder:" + userfontsfoloder);
|
|
|
-// FontSourceBase[] fontSourceBases = FontSettings.getDefaultInstance().getFontsSources();
|
|
|
-// FontSourceBase[] updatedFontSources = new FontSourceBase[FontSettings.getDefaultInstance().getFontsSources().length + 1];
|
|
|
-//
|
|
|
-// //将用户目录字体添加到字体源中
|
|
|
-// FolderFontSource folderFontSource = new FolderFontSource(userfontsfoloder, true);
|
|
|
-//
|
|
|
-// for (int i = 0; i < fontSourceBases.length; i++) {
|
|
|
-// updatedFontSources[i] = fontSourceBases[i];
|
|
|
-// }
|
|
|
-// updatedFontSources[fontSourceBases.length] = folderFontSource;
|
|
|
-//
|
|
|
-// FontSettings.getDefaultInstance().setFontsSources(updatedFontSources);
|
|
|
-//
|
|
|
-// long old = System.currentTimeMillis();
|
|
|
-// File file = new File(outPath); // 新建一个空白pdf文档
|
|
|
-// os = new FileOutputStream(file);
|
|
|
-// com.aspose.words.Document doc = new com.aspose.words.Document(inPath); // Address是将要被转化的word文档
|
|
|
-// doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
|
|
|
-// // EPUB, XPS, SWF 相互转换
|
|
|
-// long now = System.currentTimeMillis();
|
|
|
-// System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时
|
|
|
+ String userfontsfoloder = System.getProperty("user.home") + "\\Microsoft\\Windows\\Fonts\\";
|
|
|
+ System.out.println("userfontsfoloder:" + userfontsfoloder);
|
|
|
+ FontSourceBase[] fontSourceBases = FontSettings.getDefaultInstance().getFontsSources();
|
|
|
+ FontSourceBase[] updatedFontSources = new FontSourceBase[FontSettings.getDefaultInstance().getFontsSources().length + 1];
|
|
|
+
|
|
|
+ //将用户目录字体添加到字体源中
|
|
|
+ FolderFontSource folderFontSource = new FolderFontSource(userfontsfoloder, true);
|
|
|
+
|
|
|
+ for (int i = 0; i < fontSourceBases.length; i++) {
|
|
|
+ updatedFontSources[i] = fontSourceBases[i];
|
|
|
+ }
|
|
|
+ updatedFontSources[fontSourceBases.length] = folderFontSource;
|
|
|
+
|
|
|
+ FontSettings.getDefaultInstance().setFontsSources(updatedFontSources);
|
|
|
+
|
|
|
+ long old = System.currentTimeMillis();
|
|
|
+ File file = new File(outPath); // 新建一个空白pdf文档
|
|
|
+ os = new FileOutputStream(file);
|
|
|
+ com.aspose.words.Document doc = new com.aspose.words.Document(inPath); // Address是将要被转化的word文档
|
|
|
+ doc.save(os, SaveFormat.PDF);// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,
|
|
|
+ // EPUB, XPS, SWF 相互转换
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ System.out.println("pdf转换成功,共耗时:" + ((now - old) / 1000.0) + "秒"); // 转化用时
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return false;
|