PDF Unicode Support

ReportBuilder 12 introduced full unicode support for the native PDF device included with ReportBuilder. (Delphi 2009 and later). Below are some tips on how to utilize this feature and an overview of some of the new options.

Encoding

The PDF device now supports two types of font encoding. ANSI charset encoding and Unicode encoding. This can be controlled by using the PDFSettings.FontEncoding property of the report.

ANSI Encoding: Only the ANSI charset will be used for text inside the PDF file. This means the first 255 glyphs of the font will be used regardless if it is a Unicode font or not. The ANSI Encoding should be used when no Unicode text is (or will be) displayed inside the exported report. This can save space due to the fact that Unicode fonts need to be embedded inside the PDF file.

Unicode Encoding: Unicode and ANSI characters will be exported to the PDF file. The only downside to using this setting is that if a font contains Unicode characters yet the report does not have Unicode text, the font will still be embedded inside the PDF file increasing its size.

Example:

Using ANSI Encoding and a report containing text in Arial font.
File Size: 2.5 KB

Using Unicode Encoding and a report containing text in Arial font.
File Size: 120 KB

Font Subsetting

Font subsetting is necessary for effeciently exporting Unicode characters to a PDF file. This is due to the fact that all Unicode fonts need to be embedded into the PDF file itself to display the character glyphs correctly. The requirement can be troublesome in certain cases because typically Unicode fonts are very large. Arial Unicode MS for instance is over 22MB. Embedding this entire font would drastically increase the size of the PDF file.

To solve this problem, it is possible to embed a subset of the font file only containing the character glyphs used in the exported document. By default all Unicode fonts are embedded and subsetted. The only reason you would want to disable subsetting would be if there is a possibility that the PDF document being generated will be edited in the future. Since only a font subeset is embedded, only the original characters will be available when editing takes place. (Note that some editors have the ability to re-generate the font file subset).

Control font subsetting using the PDFSettings.EmbedFontOptions property.