Embedded Fonts
To match the content appearance in the browser, embed the same fonts in the exported PDF document.
The PDF Export module does not support right-to-left (RTL) scripts such as Arabic or Hebrew.
Basic Usage
To embed the fonts in the PDF document:
- Declare a font face using the
@font-facerule. - Host the TrueType fonts (
.ttf) in the domain of the application or use a CDN. - Apply the font family to the
kendo-pdf-exportelement in your component styles.
- Use the same font to style the content in the browser and in the PDF export.
- The fonts that you use may require a separate license for their embedding in PDF documents.
The following example demonstrates how to embed the DejaVu Sans font, which supports a wide range of special characters including accented letters, mathematical symbols, currency symbols, and international characters.
Character-Specific Fonts
When your content includes special characters or multiple languages, use fonts that support the required character sets. The CSS unicode-range descriptor allows you to specify which Unicode characters a font supports, enabling the browser to load only the necessary fonts.
You can declare multiple @font-face rules with different fonts for specific character ranges:
@font-face {
font-family: 'CustomFont';
src: url('path/to/latin-font.ttf') format('truetype');
unicode-range: U+0000-00FF; /* Latin characters */
}
@font-face {
font-family: 'CustomFont';
src: url('path/to/cyrillic-font.ttf') format('truetype');
unicode-range: U+0400-04FF; /* Cyrillic characters */
}
@font-face {
font-family: 'CustomFont';
src: url('path/to/arabic-font.ttf') format('truetype');
unicode-range: U+0600-06FF; /* Arabic characters */
}
Alternatively, use a comprehensive font like DejaVu Sans, Liberation Sans, or Noto Sans that supports multiple scripts and character sets in a single font file. This approach simplifies font management and ensures consistent rendering across different character types.
Advanced Scenarios
For more advanced scenarios on font embedding, refer to the article on embedding fonts from the low-level Drawing library.