pdfsharphtml-renderer

Created pdf does not display all UTF-8 characters


I'm creating a PDF document using HtmlRenderer.PdfSharp library. Back-end receives html from front-end and creates PDF using GeneratePdf() method.

PdfGenerator.GeneratePdf(html, PdfSharp.PageSize.A4);

The process works fine when standard latin characters are used in html. I've tried to pass UTF-8 test file as an input in front-end and some of the characters hasn't rendered properly as seen in attached image. When I've bypassed front-end by hard-coding html value the result was the same, so I assume the problem lays in library.

Is there a way to properly render those characters with this library? I especially care about math symbols such as ∮ or ℝ ⊂ ℂ. Rendered image


Solution

  • I've found the answer thanks to https://stackoverflow.com/a/59377248

    Setting font-family in html element containing math symbols to "Segoe UI Symbol" allowed PdfSharp to render those symbols properly.

    Character Map is an useful tool in searching for fonts that include wanted symbols.