2016-12-30 148 views

回答

2

使用Tika的任何特定要求。您可以使用專門用於文檔轉換的Apache POI & itext API或document4j API。

document4j例::

File wordFile = new 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(); 
+0

是啊其實我的項目只使用apache tika,我們不想使用一個更多的jar特別是這項工作,我認爲必須有某種方式做到這一點,但沒有得到任何在線支持 – Vipul

+1

Documents4j完美的作品,輕鬆和完美的轉換。順便說一句,你應該使用不是一個,但更多的罐子做這個特殊的工作。不要害怕包括更多的罐子到您的項目 – AMB

+1

不確定,我沒有親自嘗試。但嘗試下面的例子,而不是「HTML」嘗試「pdf」輸出。 https://gist.github.com/amferraz/bded9e9b28f416d20943 –