NullReferenceException when binding to HTML

I am using Aspose.PDF 6.9 in an ASP.NET web application to convert a web page to a PDF file. The application uses a WebRequest object to obtain the HTML, then I use BindHTML to create the PDF. The code works the first time it runs, but all subsquent attempts throw a NullReferenceException when I use the BindHTML method. If I stop the application and start it again, the code works the first time then throws NullReferenceExceptions.

The error I receive is below.

Object reference not set to an instance of an object. <?xml:namespace prefix = o ns = “urn:schemas-microsoft-com:office:office” /><o:p></o:p>

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.NullReferenceException:
Object reference not set to an instance of an object.



Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.



Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]

Ÿ.‰..ctor(“ ,  ) +56

œ.’.__(˜& ,  , IList ,  , ‑ , — ) +517

..__(_ , ™ , Int32 , — ) +11148

..__(_ , ™ , Int32 , — ) +13997

..__(_ , ™ , Int32 , — ) +13997

.­._(String ) +1155

œ.‑.__(String ) +291

Aspose.Pdf.Generator.Pdf.BindHTML(String html, String basePath) +761

BP.CME.CreatePdf.Page_Load(Object sender, EventArgs e) in C:\Transfer\VS2010\BP.CME\BP.CME\CreatePdf.aspx.cs:132

System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24

System.Web.UI.Control.LoadRecursive() +70

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3063

Hi,


Thanks for contacting support and sorry for replying you late.

We are working over this query and will get back to you soon. We are sorry for your inconvenience.

Hi,


I
have tested the scenario and I am able to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as
PDFNEWNET-33685. We will investigate this
issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Do we have any updated on this bug ??

Hi,


Thanks for your patience.

I have tested the scenario using current release version of Aspose.Pdf for .NET 7.7.0 and I am unable to notice any issue. The problem seems to be fixed due to recent fixes introduced in product. Can you please try using the new release version and in case you still face the same issue or you have any further query, please feel free to contact.

Hi,


Thanks for your patience.

We have further investigated the issue reported earlier and during our testing with latest release of Aspose.Pdf for .NET 9.6.0, the problem seems to be fixed. Please try using following code snippet and in case you still face any issue, please feel free to contact.

[C#]

const float PointsPerInch = 72F;<o:p></o:p>

// string tempFileName = Guid.NewGuid().ToString().Replace("-", string.Empty);

string sourceHtml = File.ReadAllText(@"F:\ExternalTestsData\simplePage.htm");

// Create PDF

Pdf report = new Pdf();

// Set page size and margins

report.PageSetup.PageWidth = PointsPerInch * 8.5F;

report.PageSetup.PageHeight = PointsPerInch * 11F;

report.PageSetup.Margin.Top = 10;

report.PageSetup.Margin.Left = 25;

report.PageSetup.Margin.Right = 25;

report.PageSetup.Margin.Bottom = 10;

report.BindHTML(sourceHtml); // Exception thrown here

report.Save(@"F:\ExternalTestsData\Test1.pdf");

//---------------------------------

// second time

//---------------------------------

report = new Pdf();

// Set page size and margins

report.PageSetup.PageWidth = PointsPerInch * 8.5F;

report.PageSetup.PageHeight = PointsPerInch * 11F;

report.PageSetup.Margin.Top = 10;

report.PageSetup.Margin.Left = 25;

report.PageSetup.Margin.Right = 25;

report.PageSetup.Margin.Bottom = 10;

report.BindHTML(sourceHtml); // Exception thrown here

report.Save(@"F:\ExternalTestsData\Test1.pdf");

The issues you have found earlier (filed as PDFNEWNET-33685) have been fixed in Aspose.Pdf for .NET 9.7.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.