java pptx,使用Java将文件.pptx转换为.ppt

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

解决方案

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)