PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

Problem with external font
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2341
Page 1 of 1

Author:  valerio.pisapia [ Mon Feb 25, 2013 1:31 pm ]
Post subject:  Problem with external font

Hi!
I had to develop a software to create pdf runtime.
My problems are the loading of external fonts;

Code:
XPrivateFontCollection privateFontCollection = XPrivateFontCollection.Global;
        Uri fontUri = new Uri(MappedApplicationPath + "public\\fonts\\");

LoadPrivateFont(privateFontCollection, fontUri, "./FRE3OF9X.ttf");
// Set font embedding to Always
        XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);

 protected void LoadPrivateFont(XPrivateFontCollection privateFontCollection, Uri fontUri, string sFontFamilyname)
    {
        //Every font must be added to the global font collection.  There is probably some better way to do this but this was the only method that seemed to work when deploying to any server.
        //If the font has previously been added it will just error out and continue, this does not matter.
        //try
        //{
        privateFontCollection.AddFont(fontUri + sFontFamilyname);
        //privateFontCollection.Add(fontUri, sFontFamilyname);
        //}
        //catch
        //{
        //}
    }


But this does not work...
Help me.
Thanks

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/