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(@"
<html>
    <head>
        <meta charset = 'utf-8'>
    </head>
    <body>こんにちは世界</body>
</html>
");
Dim Renderer = New IronPdf.HtmlToPdf()
Renderer.PrintOptions.InputEncoding = System.Text.Encoding.UTF8

Dim Pdf = Renderer.RenderHtmlAsPdf("
<html>
    <head>
        <meta charset = 'utf-8'>
    </head>
    <body>こんにちは世界</body>
</html>
")
VB   C#

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

Encodings Supported

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