Font mapping

Font mapping

If you have a PDF document which uses non-embedded fonts, you can specify your own font substitution map to specify which fonts need to be used. Simply create a new RenderSettings object and add your substitution to it and use the object when rendering your document.

Page page = document.Pages[0];

// get a bitmap 4 time the size of the page. This is 288 DPI, almost 300
Bitmap bmp = new Bitmap((int) page.Width * 4, (int) page.Height * 4);
using (Graphics graphics = Graphics.FromImage(bmp))
{
   graphics.ScaleTransform(4.0f, 4.0f);
   renderSettings = new RenderSettings();
   renderSettings.TextSettings.FontSubstitutionMap.Add("TallComponents Demo Font", "ariali.ttf");
   page.Draw(graphics, renderSettings);
}