【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 实现Word或Excel 转Pdf


下一篇:c# – 使用Aspose将Excel,PowerPoint,PDF和Word转换为.NET中的图像