使用Java将文件.pptx转换为.ppt [英] Convert file .pptx to .ppt using Java

查看:1335
本文介绍了使用Java将文件.pptx转换为.ppt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人知道使用Java将.pptx转换为.ppt的方法吗?

I was wondering if someone knows a way to convert .pptx to .ppt progamatically using Java?

推荐答案

你可以使用openoffice for conversion。您必须正确配置eclipse / netbeans 。你也需要jodconverter插件。
哦,记得在聆听模式中打开OO

You can use openoffice for conversion. You have to configure eclipse/netbeans properly. You need jodconverter plugin, too. oh, and remember to open OO in listening mode

package openofficeconv;
import java.io.File;
import java.net.ConnectException;

import com.artofsolving.jodconverter.DocumentConverter;
import com.artofsolving.jodconverter.openoffice.connection.*;
import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;

public class PowerpointConverter{

public static void main(String[] args) {

    File inputFile = new File("j.pptx");
    File outputFile = new File("j.pdf");

    // connect to an OpenOffice.org instance running on port 8100
    OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
    try {
        connection.connect();
    } catch (ConnectException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    // convert
    DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
    converter.convert(inputFile, outputFile);

    // close the connection
    connection.disconnect();
}
}

这篇关于使用Java将文件.pptx转换为.ppt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆