Welcome GuestLogin

PDFsharp and MigraDoc Wiki

RSS RSS

Navigation




Quick Search
»

PoweredBy
<< Previous^UpNext >>
This sample shows how to use fonts that are not installed with Windows.

PDF Output File

See the PDF file created by this sample: output.pdf (21 kB)

Screen Shots

Here is a sample screen shot:

PDF file with private fonts

Source Code

This is the source code that shows how to load private fonts from a resource (WPF build):
public void Add(Uri baseUri, string familyName)
{
  if (String.IsNullOrEmpty(familyName))
    throw new ArgumentNullException("familyName");
  if (familyName.Contains(","))
    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);
  if (String.IsNullOrEmpty(key))
    throw new ArgumentException("familyName has invalid format.");
 
  if (this.fontFamilies.ContainsKey(key))
    throw new ArgumentException("An entry with the specified family name already exists.");
 
  System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(baseUri, familyName);
 
  this.fontFamilies.Add(key, fontFamily);
}


Miscellaneous
Home
PDFsharp
FAQ
Samples
Articles
MigraDoc
FAQ
Samples
Articles

ScrewTurn Wiki version 3.0.5.600. Some of the icons created by FamFamFam.

Impressum - Legal Notice