i want to export HTML <div>
with content in Hindi (Unicode characters) to PDF in ASP.NET using C#. I've tried many different third party HTML to PDF conversion tools, such as nReco, evopdf, hiqpdf,... None of them are working properly in the sense that the Hindi text either isn't shown, or the resulting text isn't rendered correctly. For instance, if I have the text "न्यायालय,विरूद्व,डब्ल्यु"
in Unicode, the characters are rendered incorrectly.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Why am I getting UnauthorizedAccessException on th
- Correctly parse PDF paragraphs with Python
I created an HTML file
devanagari.html
: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:
In C#, you'd need something like this (see How do I load a license key?):
Then I ran this line of code:
In C#, this would be something like:
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.