【Java】使用Aspose实现office转换为pdf

public class XXXConverter {

    public XXXConverter() throws Exception {
        License license = new License();
        InputStream open = XXXConverter.class.getResource("license.xml").openStream();
        license.setLicense(open);
        open.close();
    }

    public void getWordsConverter(String oldPath, String newPath) throws Exception {
        Document doc = new Document(new FileInputStream(oldPath));
        doc.save(newPath, SaveFormat.PDF);
    }

    public void getSlidesConverter(String path, String newPath) throws Exception {
        Presentation pres = new Presentation(new FileInputStream(path));
        pres.save(newPath, SaveFormat.Pdf);
    }

    public void getExcelConverter(String path, String newPath) throws Exception {
        Workbook book = new Workbook(new FileInputStream(path));
        book.save(newPath, SaveFormat.PDF);
    }
}

猜你喜欢

转载自blog.csdn.net/T_amo/article/details/89493532