We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to handle the GDI restriction of Windows azure when creating the PDF document

Platform: ASP.NET Web Forms |
Control: PDF

How to handle the GDI restriction of Windows azure when creating PDF document?

Windows azure web application doesn’t have the elevated permission to access the system fonts, so you can face unexpected exceptions when generating the PDF document. You can work around this by attaching the TTF fonts with the Web application and access it in the program. Please refer the below code snippet for the same.


//Creating the new PDF document
PdfDocument doc = new PdfDocument();
doc.PageSettings.Size = PdfPageSize.Letter;
doc.PageSettings.Orientation = PdfPageOrientation.Portrait;
PdfPage page = doc.Pages.Add();
PdfColor color = new PdfColor(System.Drawing.Color.Black);
PdfSolidBrush brushBlack = new PdfSolidBrush(color);
//Creating the new font from the TTF file
PdfFont font = new PdfTrueTypeFont(Server.MapPath(@"~/App_Data/calibri.ttf"), 24, PdfFontStyle.Regular);
page.Graphics.DrawString("Hello World", font, PdfBrushes.Red, 0, 0);
//Save the PDF document
doc.Save("sample.pdf", HttpContext.ApplicationInstance.Response, HttpReadType.Save);
//Close the PDF document


Sample project:


2X faster development

The ultimate ASP.NET Web Forms UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile