PDFRasterizer.NET 4.0 is now available. Supports .NET Core. Renders pixel-perfectly.

Namespace TallComponents.PDF.Rasterizer.Fonts

Class ResolveFontEventArgs

The ResolveFont event data.

This event is raised in order to resolve PDF fonts to device fonts. In contrast to the font substitution map, which only plays a role for non-embedded fonts, this event will be raised for all fonts.

The first time that a particular pdf font is encountered, the system will try to resolve the font, and then raise this event to inform the client which device font it has found. The property specifies whether a font definition has been found, and if so where it has been found.

If the event handler does not change any properties of this event, the system will use the definition as indicated by the property. If the font has been resolved this is often the right thing to do. If the font is unresolved the system will use the default font.

By changing one or more event properties, the event handler can change this behavior. Not only is it possible to map unresolved fonts to different fonts than the default, but it is also possible to map resolved fonts to different font definitions.

It is also possible to map a font to a font file that has not been installed on the system. In that case one should clear the and set the to refer to the appropriate file.

If the system is able to resolve the font, based on the information provided by the event handler, it will simply use that font. If for some reason the font cannot be resolved, or if it cannot be used as requested, a new ResolveFont event will be raised. At the moment there a two cases: If the font cannot be resolved the will be set to . The and the properties will indicate which values were tried.

The code below lists a ResolveFont event handler that maps all fonts to system fonts. The code below only does some special processing for Helvetica. All other fonts are mapped to "Arial Unicode MS". void resolveFont(object sender, ResolveFontEventArgs args) { // We are going to map all non-system fonts a system font. if (args.FontLocation != FontLocation.System) { args.FontRenderMode = FontRenderMode.RenderAsFont; switch (args.PdfFontName) { case "Helvetica": args.SystemFontName = "Arial"; break; case "Helvetica-Bold": args.SystemFontName = "Arial"; args.Bold = true; break; case "Helvetica-Oblique": args.SystemFontName = "Arial"; args.Italic = true; break; case "Helvetica-BoldOblique": args.SystemFontName = "Arial"; args.Bold = true; args.Italic = true; break; default: args.SystemFontName = "Arial Unicode MS"; break; } break; } }


public class ResolveFontEventArgs : EventArgs


Download PDFRasterizer.NET 4.0
We will send you a download link

  • This field is for validation purposes and should be left unchanged.
Why do we ask your email address?
We send tips that speed up your evaluation
We let you know about bug fixes
You can always unsubscribe with one click
We never share your address with a 3rd party
Thank you for your download

We have sent an email with a download link.