0
我使用飛碟將XHTML轉換爲PDF文件。我的問題是我在PDF中有一些缺少的土耳其字符。但是我不明白,在junit測試中我沒有任何問題。我可以將XHTML文件轉換爲帶有全部土耳其文字符的PDF,而不會有任何問題。但是,如果我在部署在Tomcat上的應用程序上執行相同操作,則所有土耳其字符都會丟失。飛碟添加嵌入字體不工作在tomcat上
我做了一些調試,發現在這兩種情況下都找到'/fonts/arialuni.ttf'。我發現了一些相關的線程和itext文檔,並嘗試了所有這些。用於轉換和添加字體
String path2 = "/fonts/arialuni.ttf";
//FontFactory.register(path2);
ITextRenderer renderer = new ITextRenderer();
// renderer.getFontResolver().addFontDirectory(path2,true);
renderer.getFontResolver().addFont(path2, BaseFont.IDENTITY_H,BaseFont.EMBEDDED);
renderer.setDocumentFromString(docElem.html());
renderer.layout();
renderer.createPDF(os);
renderer.finishPDF();
baoOut.flush();
並且還
http://developers.itextpdf.com/question/how-can-i-load-font-web-infresourcesfontsfoobarttf
Flying Saucer font for unicode characters
代碼施加以下爲CSS。但結果仍然相同。
@font-face {
src: url('arialuni.ttf'); <!--src: url('/fonts/arialuni.ttf'); -->
-fs-pdf-font-embed: embed;
-fs-pdf-font-encoding: Identity-H;
}
body {
font-family: Arial Unicode MS, Lucida Sans Unicode, Arial, verdana, arial, helvetica, sans-serif;
font-size: 8.8pt;
}
有誰知道,爲什麼arialuni.tff被發現,但在Tomcat不使用?
請將您的解決方案(編輯背後的所有內容)作爲單獨的答案添加並接受它 - 否則人們會認爲它沒有答案... – Lonzak