2

I'm using TheArtOfDev's HtmlRenderer.PdfSharp to convert an HTML string to PDF in a ASP.NET web application. The HTML contains Japanese characters. The Japanese symbols are converted to ☐ ascii characters.

How can I enable UTF-8 or use a custom Japanese font? I tried the following without results:

  • Adding <head><meta charset='utf-8'></head> to the HTML string.
  • Adding <style>@font-face { font-family: myFont; src: url('path/font.ttf'); }</style> to the HTML string and then settings the font style on the element with Japanese text.
  • Try a CSS file with @font-face and calling TheArtOfDev.HtmlRenderer.PdfSharp.PdfGenerator.ParseStyleSheet
Fede G
  • 197
  • 10
  • It may have not helped you with your Japanese Character Set but you just saved my ass with the addition to the Head. I couldn't find the documentation on getting it to recognize script fonts. Thank you – Sicae Apr 09 '21 at 10:51
  • @Sicae I'm glad at least someone got it working. – Fede G Apr 12 '21 at 01:16

1 Answers1

0

I gave up on HTMLRenderer and PDFSharp and solved all my issues with TuesPechkin, a wrapper for wkhtmltopdf.

Fede G
  • 197
  • 10
  • Can you explain how you use fonts with TuesPechkin? Are there online or on a local disk? – sinsedrix Mar 23 '21 at 17:00
  • @sinsedrix I ended up not doing anything manually with fonts. I pass my HTML to TuesPechkin and it just works. – Fede G Mar 24 '21 at 00:18