2017-05-09 125 views
0

使用ITextRenderer從HTML生成泰盧固語PDF不會得到確切的字符?在PDF文件中弄破碎的人物(預期的人物信息)。附加的屏幕截圖。 enter image description here使用ITextRenderer從HTML生成泰盧固語PDF不會得到確切的字符?

我們使用下面的代碼,用於生成UTF-8 PDF與字體

1)身體* {字體家庭: 「瓦尼」,喬治亞州,襯線;}

2)文件DOC =助洗劑.parse(new ByteArrayInputStream(content.toString()。getBytes(「UTF-8」)));

3)renderer.getFontResolver()。addFont(contextPath +「fonts/VANI.TTF」,BaseFont.IDENTITY_H,BaseFont.EMBEDDED); 4)jars itext 4.2和core-render.jar

請幫助獲取PDF中的例外輸出。

回答

3

您正在使用ITextRenderer,這導致您相信您正在使用飛碟。 飛碟不是iText。 Flying Saucer是使用舊版iText的第三方產品,並未得到iText Group的認可。

舊版本的iText不支持泰盧固語。支持編寫Devenagari,Tamil,Telugu等系統......需要pdfCalligraph add-on。此插件僅適用於iText 7.我們已經撰寫了關於此主題的綜合文章white paper

如果您想將HTML與泰盧固語轉換爲PDF格式,您無法使用飛碟實現此功能。據我所知,唯一允許你這樣做的工具是iText 7,Telugy支持的pdfCalligraph add-onpdfHTML add-on將HTML轉換爲PDF的組合。

更新:

如果你想使用pdfCalligraph,您需要添加以下依賴:

<dependency> 
    <groupId>com.itextpdf</groupId> 
    <artifactId>typography</artifactId> 
    <version>[1.0,)</version> 
    <scope>compile</scope> 
</dependency> 

由於pdfCalligraph是封閉源代碼插件,您還需要添加我們的封閉源代碼庫到您的存儲庫列表:

<repositories> 
    <repository> 
     <id>central</id> 
     <name>iText Repository-releases</name> 
     <url>https://repo.itextsupport.com/releases</url> 
    </repository> 
</repositories> 

最後,您需要引入許可證密鑰機制(否則pdfCalligraph會拋出com.itextpdf.licensekey.LicenseKeyExceptionjava.io.FileNotFoundException:itextkey.xml):

<dependency> 
    <groupId>com.itextpdf</groupId> 
    <artifactId>itext-licensekey</artifactId> 
    <version>[2.0,)</version> 
    <scope>compile</scope> 
</dependency> 

你需要一個許可證密鑰(KEY),你需要加載像這樣的關鍵:

LicenseKey.loadLicenseFile(new FileInputStream(KEY)); 

KEY包含的路徑XML文件。這個XML文件是您的許可證密鑰。你可以在這裏獲得這樣一個XML文件:free trial

+2

此外,他們使用iText 4.2.0,這是iText Software從未發佈的版本,但是由ymasory/InProTopia發佈。 –

+0

能否請你解釋更多...嘗試用itext7生成泰盧固語pdf。我們仍然滿足於差距。 – user1896803

+0

@ user1896803如果你得到的內容有差距,你不使用pdfCalligraph。請注意pdfCalligraph是* closed source *。如果你想使用它,它需要一個試用許可證。你有試用許可證嗎?在本教程的第2章中搜索單詞「pdfCalligraph」:http://developers.itextpdf.com/content/itext-7-building-blocks/chapter-2-working-rootelement –

相關問題