|
Rank: Newbie Groups: Member
Joined: 12/3/2013 Posts: 9
|
I am creating a web application that generates PDF files using EO.PDF. When I execute it in my development environment works very fine but to upload it to a azure website it raises an 'Out of memory' error.
To isolate the error, I built a small application that tries to create and save a blank pdf document using a PdfDocument object and a pdfPage object. this is the code:
(Default.aspx) <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="PdfTest._Default" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" ></asp:Label> </div> </form> </body> </html>
(Default.aspx.vb) Imports EO.Pdf Imports EO.Pdf.Acm Imports EO.Pdf.Contents Imports EO.Pdf.Drawing
Public Class _Default Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try 'Create a new document Dim doc As New PdfDocument()
'Add a new page Dim page As PdfPage = doc.Pages.Add()
'Save the PDF file Dim DocPath As String = System.IO.Path.GetTempPath & "tmp001.pdf" doc.Save(DocPath)
Label1.Text = "OK"
Catch ex As Exception Label1.Text = ex.Message & "<br><br>" & ex.StackTrace End Try
End Sub
End Class
Again, it works OK in development environment, but to upload it to a test web site in azure (pdftest123.azurewebsites.net) the error is generated, so the error handler displays the following message in Label1
Out of memory.
at System.Drawing.Graphics.FromHdcInternal(IntPtr hdc) at System.Drawing.Font.ToLogFont(Object logFont) at System.Drawing.Font.ToHfont() at EO.Pdf.Internal.ep.a(j8 A_0) at EO.Pdf.Internal.ep.b(j8 A_0) at EO.Pdf.Drawing.PdfFont..ctor(j8 A_0, Single A_1) at EO.Pdf.Drawing.PdfFont..ctor(String fontName, Single fontSize, FontStyle fontStyle) at EO.Pdf.Contents.PdfContentContainer.k() at EO.Pdf.PdfDocument.a() at EO.Pdf.PdfDocument.Save(String fileName) at PdfTest._Default.Page_Load(Object sender, EventArgs e) As you can see, the error is occurring in the 'Save' command, but I am not able to interpret the specific cause much less solve the problem. I ask for help, as the PDF generation is a critical issue for my project. Sincerely Max Castro Vidal Santiago - Chile (with the help of google translator :-)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, Please check whether you are using .NET 2. If so please try to switch to .NET 4 to see if it helps. Or you can try to get this hotfix from Microsoft: http://support.microsoft.com/kb/2650146Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/3/2013 Posts: 9
|
Estimates:
I am currently using version 4.5 of the framework. Net, so would not be a problem version.
The Microsoft support article you suggest, indicates the error "Out of Memory" in "System.Drawing.Graphics.FromHdcInternal (IntPtr hdc)" object which actually matches my error, however described the situation how: "when you use a graphics object to paint in a. NET Framework 3.5-based Windows Forms application "... In my case I am developing an application in ASP Webforms in Framework 4.5 and I'm not using graphics objects but I'm trying to make a basic implementation of the basic objects pdfdocument and pdfPage from EO.PDF library.
Because of this, I'd like to confirm whether it is actually possible to perform basic implementations EO.PDF (as I describe) in Azure web sites or whether, on the contrary, EO.PDF is not compatible with Azure. This is critical for me to determine if I continue doing my development with EO.PDF or find another library that is compatible with my production environment.
Thanking you for your comments:
Max Castro Vidal Santiago - Chile
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We will look into this and get back to you as soon as possible. What version of EO.Pdf do you use?
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/3/2013 Posts: 9
|
EO.PDF v 5.0.54.2
Please check the code noted above which exposes the error in a simple way. They can also see the result directly on the azure website pdftest123.azurewebsites.net
Thank you very much for your help.
Max Castro Vidal
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We have looked into this problem. Windows Azure provide several different type of services: WebSite, Cloud Service (Web Role and Worker Role) and Virtual Machine. EO.Pdf does not work with Azure WebSite, but does work fine with Web Role, Worker Role and Virtual Machine.
The reason that it does not work with Azure WebSite is because EO.Pdf uses GDI and GDI is not supported by Azure Website. This causes the code to throw an Out of memory exception when GDI related code is hit. This limitation does not exist for Azure Web Role, Worker Role and Virtual Machine.
The easiest solution for you would be to redeploy your website as an Azure Web Role. Azure Web Role is very similar to Azure Web Site and work very much the same way both from developer and user point of view. Alternatively, you can place EO.Pdf related code into a Azure Worker Role and then call that from your Azure Web Site.
Hope this helps. Please feel free to let us know if you still have any questions.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 12/3/2013 Posts: 9
|
Thank you very much for the explicit and detailed answer as to what caused the failure and implementation alternatives.
I will test the use of Roles and tell you how it works.
Max Castro V.
|
|
Rank: Newbie Groups: Member
Joined: 12/3/2013 Posts: 9
|
Deploying of EO.PDF under Web Role works perfect. Thank you very much for your help, again.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
You are very welcome. Glad to hear that it's working for you!
|
|