UTF-8 and HTML Encoding

When working with IronPDF we often use extended character sets such as UTF-8 Encoding.

To ensure you get perfect encoding of your HTML as a PDF there are 2 places that you may wish to specify your desired charset.

  1. In your Print Options using System,.Text.Encoding
  2. In your HTML Header

These 2 properties should match to get the best result:

var Renderer = new IronPdf.HtmlToPdf();
Renderer.PrintOptions.InputEncoding = System.Text.Encoding.UTF8;

var Pdf = Renderer.RenderHtmlAsPdf(@"
        <meta charset = 'utf-8'>
Dim Renderer As var = New IronPdf.HtmlToPdf
Renderer.PrintOptions.InputEncoding = System.Text.Encoding.UTF8
Dim Pdf As var = Renderer.RenderHtmlAsPdf(""& vbLf&"<html>"& vbLf&"    <head>"& vbLf&"        <meta charset = 'utf-8'>"& vbLf&"    </head>"& vbLf&"    <body>こんにちは世界</body>"& vbLf&"</html>"& vbLf)
VB   C#

The same principle applies when working with HTML Smaps and Headers & footers.

Endocings Supported

IronPDF can support all character encoding types supported by Google Chrome. character encodings including UTF-16 , iso8859-1, Windows 1252.