2017-05-09 80 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 –

相关问题