2016-09-14 17 views
2

ロゴを含むdocx文書をpdf文書に変換しようとしています。 私はこれを試してみました:Java - docxをpdf文書に変換する

FileInputStream in=new FileInputStream(fileInput); 
XWPFDocument document=new XWPFDocument(in); 
File outFile=new File(fileOutput); 
OutputStream out=new FileOutputStream(outFile); 
PdfOptions options=null; 
PdfConverter.getInstance().convert(document,out,options); 

を、PDFドキュメントにロゴが適切な場所ではありません。

docxドキュメントとまったく同じPDFを作成する方法はありますか?

+0

おそらくdocx beca私はラスタイメージを作成してPDFに入れました。 –

+0

これを検討してください:http://stackoverflow.com/questions/3022376/how-to-convert-ms-doc-to-pdf –

答えて

1

オプションdocument4jがありますか?変換をネイティブアプリケーションに委譲します。

これは、指定されたファイルを目的の形式に変換することを理解しているネイティブアプリケーションに変換を委任することによって実現されます。

File wordFile = new File(...); 
File target = new File(...); 
IConverter converter = ... ; 
Future<Boolean> conversion = converter 
    .convert(wordFile).as(DocumentType.MS_WORD) 
    .to(target).as(DocumentType.PDF) 
    .prioritizeWith(1000) // optional 
    .schedule(); 

あなたはすぐにconvertionがインストールWordやExcelでのWindowsマシン上の "ローカルデモ" であなたの条件に合うかどうかをテストすることができます

git clone https://github.com/documents4j/documents4j.git 
cd documents4j 
cd documents4j-local-demo 
mvn jetty:run 

その後http://localhost:8080

に行きます詳細なドキュメントはこちら http://documents4j.com/#/

関連する問題