Exporting Special Characters
This article demonstrates how you can use custom fonts to export non-ASCII characters to PDF. It contains the following sections:
Description of the problem
If you do not specify a font explicitly, any non-ASCII characters the exported DOM element contains will not be exported to the PDF file. This includes some accent characters, for example:
Example: Consider the following <div> element, which contains Swedish and Japanese characters (Kanji):
<div id="foo">Västergötland(West Gothia) 日本(Japan)</div>
#foo {
background-color: grey;
color: white;
}
This is how it looks like in the browser:

Exporting this <div> to PDF would result in the following:

The special characters are missing in the exported file, because the standard fonts used in exporting to PDF do not support non-ASCII characters.
Solution
In order to export special characters such as some accent and diacritical marks, you have to use a custom font that supports them:
- The custom font file has to be included in the project
- The font has to be added to the RadClientExportManager's PdfSettings.Fonts collection
- The font must be set to the element you want to export (in this example the
<div>"foo").
Example
Here is a process of how to define a font that contains the desired symbols for export. It assumes you have the "Arial Unicode MS" font. You can replace it with other suitable fonts such as "DejaVu Sans".
-
Include the
Arial Unicode MSfont in your project'sFontsfolder. It is an extended version of the Arial font and supports Unicode characters. -
Add the font to the PdfSettings.Fonts collection.
C#protected void Page_Load(object sender, EventArgs e) { RadClientExportManager1.PdfSettings.Fonts.Add("Arial Unicode MS", "Fonts/ArialUnicodeMS.ttf"); }VBProtected Sub Page_Load(sender As Object, e As EventArgs) RadClientExportManager1.PdfSettings.Fonts.Add("Arial Unicode MS", "Fonts/ArialUnicodeMS.ttf") End Sub -
Apply the font to the
<div>"foo":CSS#foo { font-family: 'Arial Unicode MS'; background-color: grey; color: white; } -
Export the
<div>:ASP.NET<telerik:RadClientExportManager runat="server" ID="RadClientExportManager1"> <pdfsettings filename="Myfile.pdf" /> </telerik:RadClientExportManager> <input type="button" onclick="exportElement()" value="export" /> <script type="text/javascript"> function exportElement() { var exp = $find("<%= RadClientExportManager1.ClientID %>"); exp.exportPDF($telerik.$("#foo")); } </script>
See Also
-
ClientExportManager - Export Special Characters online demo
-
ClientExportManager - Change the Exported Content before Export how-to article