Free Support Forum - aspose.com

Problem with Aspose.Pdf in ASP.NET 2.0

Hi,

I’m current using an evaluation version of Aspose.Pdf. My development environment is Visual Web Developer 2005 Express Beta 2.0. I’m programming in C#. The same code that works in the aspx.cs code behind file, doesn’t work when I move it to a separate C# file in the App_Code folder. In this file, it doesn’t recognize any Aspose.Pdf types and library functions. It has no problem with this in the code behind file. But once I moved the code to a separate C# file in the same project and wrapped the code inside a new namespace and class, it no longer works. ( Moving this code into a method inside this class allows me to execute the code when I invoke the method from the code behind file.) I don’t understand why all of a sudden the keywords are no longer being recognized. I’ve added a reference to Aspose.Pdf in the project and put in “using Aspose.Pdf”. Can someone help me please?

Dear Kristy,

Thank you for considering Aspose.

I have not test Aspose.Pdf in .NET 2.0 yet. I think it has some problem when runing in .NET 2.0. I will test and try to solve the problem soon.

Thank you for your reply, and I’ll look forward to your feedback Smile

Dear Kristy,

Thank you for considering Aspose.

I have not found any problem when I test Aspose.Pdf in .NET 2.0 and Visual Studio 2005. Can you please provide an example that can reproduce the error?

Thanks for you reply. I will install VS 2005 today and let you know if aspose.pdf works on there. ( I was previously having problems because I was using Visual Web Developer beta version)

It works now that I’m using VS 2005, so I’m happy Smile

Dear Kristy,

Thank you for considering Aspose.

Some of our customers report error when using Aspose.Pdf in .Net 2.0. Please refer to Support for C# 2.0? . Can you please tell me which version of Visual Studio 2005 and Aspose.Pdf you used? How do you installed the component? Have you ever get such error message? Thank you in advance.

Well, previously, I was getting errors when I used the free Visual Web Developer 2005. But afterwards I got the Beta version of VS 2005 ( althought VS 2005 has not been released yet, Microsoft has said that it’s Beta version that just came out in the middle of April, is as good as the release version). I got the 2.1.11.0 version of Aspose. How did I install the component? For Aspose.pdf, I just downloaded and installed the msi, then replaced the aspose.pdf.dll with the latest hotfix dll. For VS 2005 beta, I just obtained the software on Watchfire’s network share and installed it on my local computer. I haven’t gotten any error since I used VS 2005 beta.
Hope that helps Smile

Hi!

I got the similar problem while working on Evaluation version of Aspose.pdf. It this b'cos of evaluation or some problem with installation?
Below is the snap shot of the error.

Thanks and Regards

Exception of type 'System.OutOfMemoryException' was thrown.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.

Source Error:

Line 4: Dim objpdf As New Pdf Line 5: objpdf.BindHTML("C:\Report.html") Line 6: objpdf.Save("C:\Report.pdf") Line 7: objpdf.Close() Line 8: objpdf = Nothing

Source File: C:\WebSites\TEST\Default.aspx.vb Line: 6

Stack Trace:

[OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.] [TypeInitializationException: The type initializer for 'x0b7ad6e52a73357d.x9ee491ab5579b9fc' threw an exception.] x0b7ad6e52a73357d.x9ee491ab5579b9fc.x663613753919b50a(Int32 xc0c4c459c6ccbd00) +0 xc702d65bb6160b84.x53db190913fbf159.x2e0db4f9f181a13e(x5a81fde529e1115c x6db9c3d7ab3266a4) +56 xc702d65bb6160b84.x53db190913fbf159.x43d795979f8fdcc3(x5a81fde529e1115c x6db9c3d7ab3266a4) +55 xc702d65bb6160b84.x5a81fde529e1115c.xe410125f7519de90(String xafe2f3653ee64ebc) +407 x3f91538e8c0de749.xaa36f84dba9d652f.x5ec1518f85fc1bbf(xb912e9429339cb81 x80010f902a1f736e, Pdf x6beba47238e0ade6) +227 Aspose.Pdf.Pdf.Save(String pdfFile) +98 Default_aspx.test() in C:\WebSites\TEST\Default.aspx.vb:6 Default_aspx.Page_Load(Object sender, EventArgs e) in C:\WebSites\TEST\Default.aspx.vb:12 System.Web.UI.Control.OnLoad(EventArgs e) +87 System.Web.UI.Control.LoadRecursive() +55 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2836 

Dear Pradnya,

Thank you for considering Aspose.

Which version do you use? I have solved this problem in the latest hot fix (2.1.14.0).

Thanks for prompt reply.

I am using Aspose.pdf version 2.1.12.0. Let me try downloding the latest hot fix.

Regards

Hi!

I downloaded the latest hot fix and my problem is solved.

But now there is some other problem. I am trying to show the pdf output on webpage and it is showing me blank pdf page. Here is the sample code that i am using.

Dim pdf As New Aspose.Pdf.Pdf

Dim memory As Stream = New MemoryStream()

Dim xmldoc As New XmlDocument

Dim xWriter As XmlTextWriter

Dim xslt As New XslTransform

xmldoc.Load(“D:\Data.xml”)

xslt.Load(CType(“D:\Transform.xsl”, String))

xslt.Transform(xmldoc, Nothing, memory, Nothing)

memory.Seek(0, SeekOrigin.Begin)

pdf.BindHTML(memory)

pdf.Save(“Test.pdf”, SaveType.OpenInBrowser, Response)

Thanks and Regards

Dear pradnya,

Thank you for considering Aspose.

I have not found any error in your code. Please:

1) Change the last line and save the document to disk. Check if the document is correct.
2) Refer to PDF isn’t generating (urgent) , check if you have the same problem.

Thanks for reply.

I tried saving file on disk and that work very fine.

If i use

pdf.Save(“Report.pdf”, SaveType.OpenInAcrobat, Me.Response)

then it shows a dialogue box asking to save the file Report.pdf, if i to save then it saves properly but if i choose to open it, then it throws an error saying file is in incorrect format.

What could be the problem? Am using Adobe Acrobat 6.0.

Thanks and Regards
Pradnya

Dear Pradnya,

Can you please send the complete code to me? I hope I can reproduce this error.

Here is the code I am testing for opening in Acrobat .

Dim pdf As Pdf = New Pdf()

pdf.BindHTML(“C:\cust.html”)

pdf.OpenType = OpenType.Auto

pdf.Save("", SaveType.OpenInAcrobat, Me.Response)

Me.Response.End()

----------------------------------------------------------------
Here is the code am trying to open pdf in Browser

Dim pdf As New Aspose.Pdf.Pdf

Dim memory As Stream = New MemoryStream()

Dim xmldoc As New XmlDocument

Dim xWriter As XmlTextWriter

Dim xslt As New XslTransform

xmldoc.Load(“D:\Data.xml”)

xslt.Load(CType(“D:\Transform.xsl”, String))

xslt.Transform(xmldoc, Nothing, memory, Nothing)

memory.Seek(0, SeekOrigin.Begin)

pdf.BindHTML(memory)

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = “application/pdf”

Response.AddHeader(“Content-Disposition”, “inline;filename=report.pdf”)

pdf.Save(“report.pdf”, Aspose.Pdf.SaveType.OpenInBrowser, Response)

Response.End()


Thanks and Regards
Pradnya

XML, XSL, and html files am using in my code are attached here

Dear pradnya,

Thank you for considering Aspose.

I have just tested your code without any line changed and all works well. Can you please try saving the corrupt document and send it to me?

Hi!

How can I save corrupt document? After the page gets loaded in the browser, all Save options are disabled.

is this problem is b’cos of evaluation version?

Regards
Pradnya

Dear Pradnya,

Thank you for considering Aspose.

I really don’t know how to get the corrupt document. But one of our customer has sent me a corrupt document.

The problem should have nothing to do with the evaluation version.

Please try:

1) Binding XML file directly instead of using memory stream;
2) remove the following line:

Response.ClearContent()

Response.ClearHeaders()

Response.ContentType = “application/pdf”

Response.AddHeader(“Content-Disposition”, “inline;filename=report.pdf”)