Export Document doesn't work when the project is hosted inside Azure cloud

Stimulsoft Reports.NET discussion
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

Export Document doesn't work when the project is hosted inside Azure cloud

Post by Jalal »

Hello,

I am working in silverlight project. When i use report.ExportDocument(StiExportFormat.Pdf, file), it works fine and i am able also to write to memory stream without any errors.

But when i add cloud service project in order to host my web application in the cloud, i got "Out of Memory Exception". Same code works fine when i unload cloud project.

I spent a lot of time trying to solve this issue but still same error.

Regards,
Jalal
Jan
Posts: 1265
Joined: Thu Feb 19, 2009 8:19 am

Export Document doesn't work when the project is hosted inside Azure cloud

Post by Jan »

Hello Jatal,

Please show me full error stack.

Thank you.
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

Export Document doesn't work when the project is hosted inside Azure cloud

Post by Jalal »

System.OutOfMemoryException was unhandled by user code
Message=Out of memory.
Source=System.Drawing
StackTrace:
at System.Drawing.Graphics.FromHwndInternal(IntPtr hwnd)
at System.Drawing.Graphics.FromHwnd(IntPtr hwnd)
at Stimulsoft.Report.Export.PdfFonts.GetFontMetrics(Font font, PdfFontInfo currentFontInfo, UInt16[] glyphMap)
at Stimulsoft.Report.Export.PdfFonts.InitFontsData()
at Stimulsoft.Report.Export.StiPdfExportService.ExportPdf(StiReport report, Stream stream, StiPdfExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, StiExportService exportService, Stream stream, StiExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, Stream stream, StiExportSettings settings)
at Stimulsoft.Report.StiReport.ExportDocument(StiExportFormat exportFormat, Stream stream)
at TestPP.Web.ExportDocument.ExportDocument2Pdf(String documentTypeId, String xmlData, String internalDocumentId) in C:\Users\Jalal.DOMAIN\Documents\Visual Studio 2010\Projects\estPP.Web\ExportDocument.asmx.cs:line 107
InnerException:


using (MemoryStream memstr = new MemoryStream())
{
report.ExportDocument(StiExportFormat.Pdf, memstr); // Error occurred here!
}
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Export Document doesn't work when the project is hosted inside Azure cloud

Post by Ivan »

Hello,

We made some tests in this direction. Azure have strange troubles when we start using gdi or gdi plus.

We added a new feature. Now export to PDF can use previously prepared font files, and GDI functions are not invoked in the export process.
How it works:
- using the utility, that is attached to the e-mail, you create font files (*.fiz)
- in the init part of your application you load these files to the font store, for example:

Stimulsoft.Report.Export.FontsInfoStore.LoadFontInfoToStore("Arial", @"D:\Arial.fiz");

- export searches these fonts in the store first; if they are found then it uses them from the store, if it does not find them then it gets them from GDI as it was realized earlier.

Thank you.
Attachments
657.FontsInfoCreator.zip
(99.12 KiB) Downloaded 455 times
Jalal
Posts: 66
Joined: Sat Oct 09, 2010 4:10 am
Location: Palestine

Export Document doesn't work when the project is hosted inside Azure cloud

Post by Jalal »

Hello Ivan,

Loading Font type solve the issue. It works well now.

Thanks a lot.

Regards,
Jalal
Andrew
Posts: 4104
Joined: Fri Jun 09, 2006 3:58 am

Export Document doesn't work when the project is hosted inside Azure cloud

Post by Andrew »

Hello,

Great! Have a good day!
jansenlam
Posts: 5
Joined: Thu Oct 18, 2018 5:40 am

Re: Export Document doesn't work when the project is hosted inside Azure cloud

Post by jansenlam »

Hi,

I know it is 8 years before topics. But I encounter exactly the same issue on PDF export that if my Application hosted on Azure App Service.

If the report is using Arial font only, the above method LoadFontInfoToStore solve the issue.

However, if the report is using "Arial Unicode MS" font, "Out of Memory Exception" occurred again.

Am I missing something?

Regards,
Jansen
Lech Kulikowski
Posts: 6247
Joined: Tue Mar 20, 2018 5:34 am

Re: Export Document doesn't work when the project is hosted inside Azure cloud

Post by Lech Kulikowski »

Hello,

Please clarify which product and version are you use?

Thank you.
jansenlam
Posts: 5
Joined: Thu Oct 18, 2018 5:40 am

Re: Export Document doesn't work when the project is hosted inside Azure cloud

Post by jansenlam »

It is Stimulsoft.Reports.Web 2018.3.1.0.

I can recreate the issue using the sample download from
https://www.stimulsoft.com/en/samples/a ... the-viewer

If nothing is modified and deploy it to Azure App Service, Out of Memory occurred. (No problem if running locally)

If Arial.fiz is created and added these lines to Page_Load

Code: Select all

            
            string fontPath = Server.MapPath("Data/Arial.fiz");
            Stimulsoft.Report.Export.FontsInfoStore.LoadFontInfoToStore("Arial", fontPath);
Issue resolved.

However, if the font in report are changed from "Arial" to "Arial Unicode MS" (or even just add one text box that the font is "Arial Unicode MS")

Create the "Arial Unicode MS.fiz" and modified the code in Page_Load

Code: Select all

 
            string fontPath = Server.MapPath("Data/Arial.fiz");
            Stimulsoft.Report.Export.FontsInfoStore.LoadFontInfoToStore("Arial", fontPath);
            string fontPath2 = Server.MapPath("Data/Arial Unicode MS.fiz");
            Stimulsoft.Report.Export.FontsInfoStore.LoadFontInfoToStore("Arial Unicode MS", fontPath2);


Out of Memory Exception occurred again by selecting "Save" > "Adobe PDF File..."

Here is the deployed site for the testing

https://showreportintheviewer2018102008 ... sites.net/

Any help is appreciated.

Regards
Jansen
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Export Document doesn't work when the project is hosted inside Azure cloud

Post by HighAley »

Hello, Jansen.

It seems that the issue is connected with getting font file on Azure.

We have created the FontInfoCreator utility.

This project creates a font info file for the PDF export that allows using the fonts on Azure Web Sites and other servers that have a restriction on access to GDI+.
To use the font info file you should add the information about the necessary fonts to FontsInfoStore with the following:
Stimulsoft.Report.Export.FontsInfoStore.LoadFontInfoToStore("Arial", "Arial.fiz");

This utility allows of getting these files data for the export without the need to use GDI.

Thank you.
Post Reply