我的應用程序是MVC4 c#,我使用itextsharp生成PDF文件。要打印特殊字符≥,我使用:itextsharp ARIALUNI.TTF複製託管服務器
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);
當我發佈一個共享的主機服務器上的應用程序,得到這個錯誤:
C:\Windows\Fonts\ARIALUNI.TTF not found as file or resource.
文件複製到內容目錄,並試圖用:
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);
我得到以下錯誤:
ARIALUNI.TFF' with 'Identity-H' is not recognized.
希望你的建議。
使用此答案我得到NullReferenceException。你能幫我解決嗎? –