標籤:[] http oid udf tco err getc config map
安裝 Aspose.Words.jdk16.jar 到本地 maven repository:
mvn install:install-file -Dfile=Aspose.Words.jdk16.jar -DgroupId=com.aspose -DartifactId=aspose-words -Dversion=13.9.0.0 -Dpackaging=jar
pom.xml 檔案中依賴:
<dependency> <groupId>com.aspose</groupId> <artifactId>aspose-words</artifactId> <version>13.9.0.0</version></dependency>
license.xml 檔案置於 Resource 目錄下:
<License> <Data> <Products> <Product>Aspose.Total for Java</Product> <Product>Aspose.Words for Java</Product> </Products> <EditionType>Enterprise</EditionType> <SubscriptionExpiry>20991231</SubscriptionExpiry> <LicenseExpiry>20991231</LicenseExpiry> <SerialNumber>23dcc79f-44ec-4a23-be3a-03c1632404e9</SerialNumber> </Data> <Signature> sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU= </Signature></License>
html 檔案轉 doc 的 demo:
package com.demo.core.util;import com.aspose.words.Document;import com.aspose.words.License;import com.aspose.words.LoadOptions;import freemarker.template.Configuration;import freemarker.template.Template;import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;import java.io.*;import java.util.Map;public class WordUtil { private static final Logger logger = LogManager.getLogger(); private static String getWebRootAbsolutePath() { String folderPath = WordUtil.class.getProtectionDomain().getCodeSource().getLocation().getPath(); //if (folderPath.indexOf("WEB-INF") > 0) { return folderPath.substring(0, (folderPath.indexOf("classes") + "classes".length())); //} } /** * 擷取註冊檔案 */ public static void getLicense() { String path = getWebRootAbsolutePath() + "/license.xml"; InputStream is; try { is = new FileInputStream(new File(path)); License license = new License(); license.setLicense(is); } catch (FileNotFoundException e) { logger.error("license.xml file not found"); } catch (Exception e) { logger.error("license register failed"); } } public static void main(String[] args) throws Exception { getLicense(); LoadOptions loadOptions = new LoadOptions(); loadOptions.setLoadFormat(com.aspose.words.LoadFormat.HTML); Document doc = new Document("C:\\Users\\GeBron\\Desktop\\a.html", loadOptions); doc.save("C:\\Users\\GeBron\\Desktop\\123.doc"); }}
Aspose.Words.jdk16.jar 下載:
http://download.csdn.net/download/gebron/9898668
Aspose.Words for java 樣本