Aspose.words for Java Example

Source: Internet
Author: User
Tags log4j

Install Aspose.Words.jdk16.jar to local maven repository:

MVN install:install-file-dfile=aspose.words.jdk16.jar-dgroupid=com.aspose-dartifactid=aspose-words-dversion= 13.9.0.0-dpackaging=jar

Dependencies in the Pom.xml file:

<Dependency>    <groupId>Com.aspose</groupId>    <Artifactid>Aspose-words</Artifactid>    <version>13.9.0.0</version></Dependency>

License.xml files are placed in the Resource directory:

<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 File to Doc Demo:

 PackageCom.demo.core.util;Importcom.aspose.words.Document;ImportCom.aspose.words.License;Importcom.aspose.words.LoadOptions;Importfreemarker.template.Configuration;Importfreemarker.template.Template;ImportOrg.apache.logging.log4j.LogManager;ImportOrg.apache.logging.log4j.Logger;ImportJava.io.*;ImportJava.util.Map; Public classWordutil {Private Static FinalLogger Logger =Logmanager.getlogger (); Private Staticstring Getwebrootabsolutepath () {string FolderPath= Wordutil.class. Getprotectiondomain (). Getcodesource (). GetLocation (). GetPath (); //if (Folderpath.indexof ("Web-inf") > 0) {        returnFolderpath.substring (0, (Folderpath.indexof ("classes") + "classes". Length ())); //}    }    /*** Get registration file*/     Public Static voidGetlicense () {String path= Getwebrootabsolutepath () + "/license.xml";        InputStream is; Try{ is=NewFileInputStream (NewFile (path)); License License=NewLicense ();        License.setlicense (IS); } Catch(FileNotFoundException e) {logger.error ("License.xml File not Found"); } Catch(Exception e) {logger.error ("License Register Failed"); }    }     Public Static voidMain (string[] args)throwsException {getlicense (); Loadoptions loadoptions=Newloadoptions ();        Loadoptions.setloadformat (Com.aspose.words.LoadFormat.HTML); Document Doc=NewDocument ("c:\\users\\gebron\\desktop\\a.html", loadoptions); Doc.save ("C:\\users\\gebron\\desktop\\123.doc"); }}

Aspose.Words.jdk16.jar Download:

http://download.csdn.net/download/gebron/9898668

Aspose.words for Java Example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.