你的服務器上安裝開放式辦公。它會將「docx,doc」文檔轉換爲「.pdf」。
package naveed.workingfiles;
import java.io.*;
import com.artofsolving.jodconverter.openoffice.connection.*;
import com.artofsolving.jodconverter.openoffice.converter.*;
import com.artofsolving.jodconverter.*;
public class DocToPdf {
public static void main(String[] args) throws Exception {
//Creating the instance of OpenOfficeConnection and
//passing the port number to SocketOpenOfficeConnection constructor
OpenOfficeConnection con = new SocketOpenOfficeConnection(8100);
//making the connection with openoffice server
con.connect();
// making the object of doc file and pdf file
File inFile = new File("Naveed.docx");
//this is the final converted pdf file
File outFile = new File("NaveedPdf.pdf");
//making the instance
DocumentConverter converter = new OpenOfficeDocumentConverter(con);
//passing both files objects
converter.convert(inFile, outFile);
con.disconnect();
}
}
謝謝,但我不允許地方安裝的東西,這是不是一種選擇;) – Mirco
但沒有tooo多google搜索this..i得到這個solution.it作品 –