首页 > 代码库 > Aspose.Words for java 示例
Aspose.Words for java 示例
安装 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 示例
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。