Html Div (with tags and Hindi Unicode) to PDF in asp.net c#

只愿长相守 提交于 2019-12-08 15:18:32

I created an HTML file devanagari.html:

<body>
<div>न्‍यायालय,विरूद्व,डब्‍ल्‍यु</div>
</body>

And I converted this file to PDF using iText 7 + the pdfHTML add-on + the pdfCalligraph add-on.

You can see the result in the following screen shot:

To make this work, I first loaded my iText 7 license key to activate iText 7 and the twoo add-ons:

LicenseKey.loadLicenseFile(System.getenv("ITEXT7_LICENSEKEY") + "/itextkey.xml");

In C#, you'd need something like this (see How do I load a license key?):

LicenseKey.LoadLicenseFile("path/to/itextkey.xml");

Then I ran this line of code:

HtmlConverter.convertToPdf(new File(src), new File(dest));

In C#, this would be something like:

HtmlConverter.ConvertToPdf(src, dest);

where src refers to your HTML, and dest to the resulting PDF.

As far as I can tell from the screen shot, the content is rendered correctly. Most other tools will render the text like this (if they render anything at all):

Obviously, that is incorrect because no ligatures were made.

For more info about converting HTML to PDF with iText, please consult the HTML to PDF tutorial. For instance: if you want to use a different font than the default font that is shipped with pdfHTML (FreeSans), you should consult chapter 6: Using fonts in pdfHTML.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!