【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);
    }
}

 

你可能感兴趣的:(java)