HtmlToPdf Constructor (Boolean, Encoding, String, String)
Creates an instance of HtmlToPdf class for use with international charsets.

Namespace: MailBee.Pdf
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.4 build 677 for .NET 4.5
Syntax
public HtmlToPdf(
	bool autodetectSourceEncoding,
	Encoding sourceEncoding,
	string pdfCharset,
	string systemFontsFolder
)

Parameters

autodetectSourceEncoding
Type: SystemBoolean
If true, MailBee will try to detect the encoding of the source HTML input from META tag first; otherwise, MailBee will always use sourceEncoding even if the encoding is specified directly in the source HTML with META tag.
sourceEncoding
Type: System.TextEncoding
Denotes the encoding of the input HTML or plain-text, or if a null reference (Nothing in Visual Basic), MailBee will use the default encoding of the current system. However, if autodetectSourceEncoding set to true, MailBee will try to auto-detect the source encoding and will fall back to sourceEncoding only if META tag is missing or does not contain charset declaration.
pdfCharset
Type: SystemString
The charset name for the default output font. UTF-8, UTF-7 as long as any other Unicode charsets are not allowed. If a null reference, will detect the output charset from the input encoding (which in turn can be autodetected, can be system's default, or can be manually set).
systemFontsFolder
Type: SystemString
The path to the Windows fonts folder. If a null reference, system fonts won't be available.
Remarks

This overload contains extra parameters which let you create PDF documents in non-English languages like Turkish, Hebrew, Cyrillic, and a few others. It also lets you use Windows fonts in addition to the built-in fonts which come with the library.

The default built-in fonts support only "windows-1252" charset which covers English and other Western European languages. If you need more languages or more fonts, you'll need to enable Windows fonts. Make sure that your application has permissions to read the fonts folder. Because this folder resides in Windows folder (somewhat like "C:\WINDOWS\Fonts") and your application may have limited access to it, you may need to copy the fonts you need to a separate folder which your application can read. This may be especially important for web applications.

To refer Windows fonts folder (assuming your application has permissions to read its contents), use Environment.SystemDirectory + @"\..\Fonts" in C# or Environment.SystemDirectory & "\..\Fonts" in VB.

autodetectSourceEncoding and sourceEncoding parameters lets you specify the encoding of the source data or auto-detect it if possible. pdfCharset parameter denotes the charset name of the encoding which will be used to produce the PDF document (such as "windows-1252", etc). Internally, this value is used to pick up the correct font to load. Currently, the component supports charsets specified as windows-125x (such as "windows-1251"). Charsets which cannot be specified this way are not yet supported (this includes Far East languages like Chinese and Japanese). Also, the component does not yet support right-to-left languages (Hebrew and Arabic).

In fact, pdfCharset and systemFontsFolder parameters specify how DefaultFont is created. MailBee uses systemFontsFolder when calling iTextSharp.text.FontFactory.RegisterDirectory and passes pdfCharset as second parameter when calling iTextSharp.text.FontFactory.GetFont.

The HtmlToPdf() overload of this constructor is equivalent to HtmlToPdf(true, Encoding.UTF8, null, null) (in C# syntax).

This overload requires the license key be already set (such as with MailBee.Global.LicenseKey property, app.config, web.config, or in Windows registry).

Examples
See Also