Aspose.slides记录(一)

来源:互联网 发布:python 汉字编码 编辑:程序博客网 时间:2024/05/18 17:59

前言

Aspose.slides是一款处理pptx的商业软件,由于业务需要对pptx中文本框/形状/备注/图表等各个模块中的文本及格式进行编辑,在尝试POI/DOM4J之后使用Aspose进行业务处理,并将问题及使用情况进行记录.

获取liscense

    static{        InputStream is = null;        try {            ClassLoader loader = Thread.currentThread().getContextClassLoader();            is = loader.getResourceAsStream("licenseOfSlides.xml");            License aposeLic = new License();            aposeLic.setLicense(is);        } catch (Exception e) {            e.printStackTrace();        } finally {            IOUtils.closeQuietly(is);        }    }

创建对象及保存

    public void readAndSave(File inFile,File outFile) throws FileNotFoundException{        InputStream in = null;        OutputStream out = null;        if (inFile != null) {            in = new FileInputStream(inFile);        }        if (outFile != null) {            out = new FileOutputStream(outFile);        }        // 生成presentation对象        Presentation pres = new Presentation(in);        // 保存为pptx        pres.save(out, SaveFormat.Pptx);        // 保存为ppt        pres.save(out, SaveFormat.Ppt);        // 保存为pdf        pres.save(out, SaveFormat.Pdf);    }
原创粉丝点击