JAVA Word转PDF的demo

第一步下载相关JAR包,由于aspose是收费的我这里提供已经破解好的的jar包链接发给大家可点击下载aspose完美破解版
或者复制链接下载:https://download.csdn.net/download/sou_time/10449987
package wordtopdf;

/**
 *
 * @author dizhang
 * @date 2018-5-31 10:39:49
 */
import java.io.*;
import com.aspose.words.*;       

public class Word2Pdf {

    /**
     * 
     * @param Address 需要转换的路径
     */
    public static void word2pdf(String Address) {
        try {
            File file = new File("E:/1234.pdf");  //新建一个空白pdf文档           
            FileOutputStream os = new FileOutputStream(file);
            Document doc = new Document(Address);  //Address是将要被转化的word文档      
        //    doc.setFontSettings(1);
           
            doc.save(os, SaveFormat.PDF); //全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF, EPUB, XPS, SWF 相互转换         
            os.close();       
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
 
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package wordtopdf;

/**
 *
 * @author dizhang
 */
public class WordToPdf {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Word2Pdf.word2pdf("E:/1234.docx");
        } catch (Exception e) {
            System.out.print(e);
        }
    }

}



猜你喜欢

转载自blog.csdn.net/sou_time/article/details/80524484