2013-05-17 73 views
6

イメージやその他のPDFを含む任意の量のファイルからPDFを作成するためにApache PDFBox(http://pdfbox.apache.org/)を使用しています。今私はMS Officeのドキュメント(Word、ExcelとOutlookのMSG)をPDFに追加する必要があります。ファイルにはほぼすべてのOfficeバージョンが含まれるため、ファイルが新しいオフィスファイル(docxなど)または古いファイル(docなど)であることは認められません。MS OfficeドキュメントをApache経由でPDFに追加するPDFBox

フリーツールでのみこれを行う方法はありますか?私の最初のアイデアは、Apache POI(http://poi.apache.org/)ですべてのファイルのcontnetを読み込んで新しいPDFページとして再作成することですが、このPDFの作成は50人以上のサーバーで使用されるため、非常にコストがかかる可能性があります。

答えて

4

あなたのオフィスにopen officeをインストールします。 "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(); 
    } 

} 
+0

おかげで、私はどこかで何かをインストールすることは許されないのです、これはオプションではありません。) – Mirco

+0

しかしtoooがはるかにthis..iのためにグーグルでしたが、このsolution.it作品を得ました –

関連する問題