My application is MVC4 c#, I am using itextsharp to generate PDF files. To print special characters ≥, I use:
string ARIALUNI_TFF = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "ARIALUNI.TTF");
var bf = BaseFont.CreateFont(ARIALUNI_TFF, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
var f = new Font(bf, 10, Font.NORMAL);
When I published the application on a shared hosting server, got this error:
C:\Windows\Fonts\ARIALUNI.TTF not found as file or resource.
Copied the file to Content directory and tried to use:
string ARIALUNI_TFF1 = System.Web.HttpContext.Current.Server.MapPath("~/Content/ARIALUNI.TFF");
// FontFactory.Register(ARIALUNI_TFF1);
var bf1 = BaseFont.CreateFont(ARIALUNI_TFF1, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
var f1 = new Font(bf1, 10, Font.NORMAL);
I get the following error:
ARIALUNI.TFF' with 'Identity-H' is not recognized.
Would appreciate your suggestions.
I replaced:
string fontpath = System.Web.HttpContext.Current.Server.MapPath("~/Content/ARIALUNI.TFF");I replaced:
var bf = BaseFont.CreateFont(fontpath, BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
var f = new Font(bf, 10, Font.NORMAL);
with
string fontpath = System.Web.HttpContext.Current.Server.MapPath("~/Content/");
BaseFont bf = BaseFont.CreateFont(fontpath + "ARIALUNI.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
Font f = new Font(bf, 10, Font.NORMAL);
It worked.