word 转pdf && 反编译工具

反编译工具下载页面:https://github.com/GraxCode/J...
word 转pdf && 反编译工具_第1张图片


word 转pdf && 反编译工具_第2张图片


       
           AsposeJavaAPI
           Aspose Java API
           http://repository.aspose.com/repo/
       
       
           com.e-iceblue
           http://repo.e-iceblue.cn/repository/maven-public/
       
   
  



           com.aspose
           aspose-words
           18.8
       
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");
    }

word 转pdf && 反编译工具_第3张图片

你可能感兴趣的:(pdf)