@THHO I'm giving up and finding an alternative PDF creator - unless the missing sample is provided on (
http://www.pdfsharp.net/wiki/PrivateFonts-sample.ashx) soon.
On the web there is no simple way to use PdfSharp of MigraPdf. Embedding Font's as embedded resources on the Project that references has a Nuget reference to "PDFsharp-MigraDoc-gdi" doesn't work.
I get the following error:
[InvalidOperationException: Cannot retrieve font data.]
PdfSharp.Fonts.FontResolverBase.GetFontData(Byte[]& data, String familyName, Boolean isBold, Boolean isItalic) +311
PdfSharp.Fonts.FontResolverBase.ResolveTypeface(String familyName, Boolean isBold, Boolean isItalic) +124
PdfSharp.Fonts.DefaultFontResolver.ResolveTypeface(String typefaceName, Boolean isBold, Boolean isItalic) +17
PdfSharp.Fonts.GlobalFontSettings.ResolveFont(XFont font) +75
PdfSharp.Fonts.OpenType.OpenTypeFontface..ctor(XFont font, XPdfFontOptions options) +68
PdfSharp.Fonts.OpenType.OpenTypeDescriptor..ctor(XFont font, XPdfFontOptions options) +97
PdfSharp.Fonts.FontDescriptorStock.CreateOpenTypeDescriptor(XFont font) +134
PdfSharp.Fonts.FontDescriptorStock.CreateDescriptor(XFont font) +126
PdfSharp.Drawing.XFont.get_Metrics() +34
PdfSharp.Drawing.XFont.Initialize() +170
PdfSharp.Drawing.XFont..ctor(String familyName, Double emSize, XFontStyle style) +51
PdfSharp.Drawing.XGraphicsPath.AddString(String s, XFontFamily family, XFontStyle style, Double emSize, XRect layoutRect, XStringFormat format) +143
PdfSharpMigraDocTest.getClock.DrawText(XGraphics gfx, XPen pen, XBrush brush) in c:\Dev\qwe\Spikes\PDF\PdfSharpMigraDocTest\getClock.aspx.cs:78
I am tempted to give '
System.Windows.Media.FontFamily fontFamily = new System.Windows.Media.FontFamily(baseUri, familyName);
fontFamilies.Add(key, fontFamily);'
a go if it existed in MigraPDF but sadly not, or if the URI for my font was obtainable.
Maybe the Uri for local nonGAC registered DLL embedded fonts is per <http://stackoverflow.com/questions/350027/setting-wpf-image-source-in-code> : i.e. new Uri("pack://application:,,,/AssemblyName;component/Resources/Verdana.ttf");