This sample shows how to use fonts that are not installed with Windows.Note:
This sample shows how to use the XPrivateFontcollection class that is supported by the GDI build of PDFsharp only.
Applications that use CORE or WPF builds of PDFsharp 1.50 or MigraDoc 1.50 have to use the FontResolver class.
PDFsharp Sample: Font Resolver
PDF Output File
See the PDF file created by this sample: output.pdf
Here is a sample screen shot:
This is the source code that shows how to load private fonts from a resource (WPF build):
public void Add(Uri baseUri, string familyName)
throw new ArgumentNullException("familyName");
throw new NotImplementedException("Only one family name is supported.");
// family name starts right of '#'
int idxHash = familyName.IndexOf('#');
if (idxHash < 0)
throw new ArgumentException("Family name must contain a '#'. Example './#MyFontFamilyName'", "familyName");
string key = familyName.Substring(idxHash + 1);
throw new ArgumentException("familyName has invalid format.");
throw new ArgumentException("An entry with the specified family name already exists.");
System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(baseUri, familyName);
The samples on this site usually show and discuss code snippets only. The complete source code of the samples with solutions for Visual Studio is available from the download area on CodePlex