word 转pdf && 反编译工具

linyelai

反编译工具下载页面:https://github.com/GraxCode/J...
image.png


image.png

<repositories>
       <repository>
           <id>AsposeJavaAPI</id>
           <name>Aspose Java API</name>
           <url>http://repository.aspose.com/repo/</url>
       </repository>
       <repository>
           <id>com.e-iceblue</id>
           <url>http://repo.e-iceblue.cn/repository/maven-public/</url>
       </repository>
   </repositories>
  
<dependencies>

<dependency>
           <groupId>com.aspose</groupId>
           <artifactId>aspose-words</artifactId>
           <version>18.8</version>
       </dependency>
</dependencies>
public class Doc2Pdf {

    public  boolean getLicense() {
        boolean result = false;
        try {
            ClassLoader classLoader = Doc2Pdf.class.getClassLoader();
            InputStream is =classLoader.getResourceAsStream("license.xml"); // license.xml应放在…\WebRoot\WEB-INF\classes路径下
            License aposeLic = new License();
            aposeLic.setLicense(is);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }

    public  void doc2pdf(String Address) {

        if (!getLicense()) { // 验证License 若不验证则转化出的pdf文档会有水印产生
            return;
        }
        try {
            long old = System.currentTimeMillis();
            File file = new File("d:/pdf1.pdf"); //新建一个空白pdf文档
            FileOutputStream os = new FileOutputStream(file);
            Document doc = new Document(Address); //Address是将要被转化的word文档
            doc.save(os, SaveFormat.PDF);//全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换
            long now = System.currentTimeMillis();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static  void main(String [] args){
        Doc2Pdf doc2Pdf = new Doc2Pdf();
        doc2Pdf.doc2pdf("d:/images/Word.docx");
    }

image.png

阅读 342

真正的大师,永远怀着一颗学徒的心

53 声望
9 粉丝
0 条评论
你知道吗?

真正的大师,永远怀着一颗学徒的心

53 声望
9 粉丝
宣传栏