不囉唆
我想做的就是標題的 convert docx to pdf
先拜見這個官方網頁
https://code.google.com/p/xdocreport/wiki/Overview
該有的jar 請參考官方的example (如果你又下載apache POI and iText 天知道版本會不會衝突)
所以~ 用example 的 比較保險。
好啦!~ 照範例 做完後 英文~ ok
中文~ 死一片 ???? ??? ???? ????
這不是重點甚麼是重點!! 就是中文!!
參考issue 81
https://code.google.com/p/xdocreport/issues/detail?id=81
有高手說要改成
PdfOptions options = PdfOptions.create();
options.fontProvider( new IFontProvider()
{
public Font getFont( String familyName, String encoding, float size, int style, Color color )
{
try
{
BaseFont bfChinese =
BaseFont.createFont( "c:/Windows/Fonts/arialuni.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED );
Font fontChinese = new Font( bfChinese, size, style, color );
if ( familyName != null )
fontChinese.setFamily( familyName );
return fontChinese;
}
catch ( Exception e )
{
e.printStackTrace();
return null;
}
}
} );
PdfConverter.getInstance().convert( document, out, options );
沒錯!! 先建個 interface 就行了!! (only for windows!)
先解決這個問題了~
好啦!~~ 接下來轉轉看doc to pdf........ 恩.... 不支援 ...
- you create a document with MS Word (docx, pptx) or OpenOffice (odt, ods)
oh~~ no ~~~ 忘了看這東西....
先補上 code
放遺憾的沒力~ 停在這裡~~