隐藏

Aspose.slides记录

发布:2020/2/12 16:25:53作者:管理员 来源:本站 浏览次数:959

前言

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13

创建对象及保存

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