I want to apply Trade gothic font to my pdf text using PDFsharp, I installed the font and use below line of code to apply
XPdfFontOptions options = new XPdfFontOptions(PdfFontEncoding.Unicode, PdfFontEmbedding.Always);
// var options = new XPdfFontOptions(PdfFontEmbedding.Always);
XFont font = new XFont("TRADE GOTHIC BOLD CONDENSED NO. 20", 20, XFontStyle.Bold, options);
But it does not work !!. I also wanted to know that in production I use a Windows 2008 server, is there a way I can dynamically add this font to the production server, even if it is not?
As I suggested, I went to the pdfsharp forum, this is my sample code
XPrivateFontCollection privateFontCollection = XPrivateFontCollection.Global;
// Uri fontUri = new Uri(MappedApplicationPath + "Fonts\\trade-gothic-no-20-condensed-bold-1361518746.ttf");
Uri fontUri = new Uri("C:\\inetpub\\wwwroot\\wss\\VirtualDirectories\\80\\Fonts\\trade-gothic-no-20-condensed-bold-1361518746.ttf");
LoadPrivateFont(privateFontCollection, fontUri, "./#TradeGothicNo.20-Condensed");
I tried all possible combination of path and file name, the name given in the .ttf file, but still getting the exception. I have a sharepoint Visual webpart and a page load event for this website writing this code.
This is the boot method.
protected void LoadPrivateFont(PdfSharp.Drawing.XPrivateFontCollection privateFontCollection, Uri fontUri, string sFontFamilyname)
{
try
{
privateFontCollection.Add(fontUri, sFontFamilyname);
}
catch
{
}
}
I followed this entry
http://forum.pdfsharp.net/viewtopic.php?f=2&t=1880
thank