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. (Last updated on : Nov 16th 2018).
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

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.

C#

//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

doc.Close(true);

 

 

Sample project:

http://www.syncfusion.com/downloads/support/directtrac/general/ze/PDFFontTest827240610

 

Article ID: Published Date: Last Revised Date: Platform: Control:
5830 11/30/2015 11/30/2015 ASP.NET Web Forms PDF
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

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