Aspose.Words for java 樣本

來源:互聯網
上載者:User

標籤:[]   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 樣本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.