We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Aspose PDF stopes working after few hours

Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

We are getting following error when opening converting HTML to PDF:

***Logging started***

29/10/2013 2:49:50 PM ReportsPDF - ExportToPDF - : Template ReadE:/ARMS/HTMFiles/rptIndex_of_Organisation_And_Agency_Names_read.htm

System.NullReferenceException Object reference not set to an instance of an object. at


.š.[1](String , Pdf , Section , Text )

at


.š.[1](Pdf , Section , Cell , Text , HeaderFooter , [1] , ‹ )

at


.š.[1](Pdf , Section , Table , Cell , Text , HeaderFooter , [1] , ‹ )

at


.œ.[1](Pdf , Section , HeaderFooter , Table , Row , Cell , Text , [1] , ‹ , Boolean )

at


..[1](Pdf , Section , [1] )

at


..[1](Pdf )

at


..[1]( , Pdf )

at Aspose.Pdf.Generator.Pdf.Save(String fileName, SaveType saveType, HttpResponse response)

at ArmsRepository.ARMSReportHelper.ExportToPDF(String readTemplate, HttpResponse response, String[] sHeaderFooter, String sReportNumber) in E:\ArMS_Bh\ECS.ArMS.Repository\ARMSReportHelper.cs:line 3734

***Logging ended***

***Logging started***

29/10/2013 2:49:50 PM ReportsPDF - ReportGridView_RowCommand

System.NullReferenceException Object reference not set to an instance of an object. at


.š.[1](String , Pdf , Section , Text )

at


.š.[1](Pdf , Section , Cell , Text , HeaderFooter , [1] , ‹ )

at


.š.[1](Pdf , Section , Table , Cell , Text , HeaderFooter , [1] , ‹ )

at


.œ.[1](Pdf , Section , HeaderFooter , Table , Row , Cell , Text , [1] , ‹ , Boolean )

at


..[1](Pdf , Section , [1] )

at


..[1](Pdf )

at


..[1]( , Pdf )

at Aspose.Pdf.Generator.Pdf.Save(String fileName, SaveType saveType, HttpResponse response)

at ArmsRepository.ARMSReportHelper.ExportToPDF(String readTemplate, HttpResponse response, String[] sHeaderFooter, String sReportNumber) in E:\ArMS_Bh\ECS.ArMS.Repository\ARMSReportHelper.cs:line 3785

at ArmsRepository.ArMSRepository.ExportToPDF(String readTemplate, HttpResponse response, String[] sHeaderFooter, String sReportNumber) in E:\ArMS_Bh\ECS.ArMS.Repository\ArMSRepository.cs:line 409

at ECS.ArMS.ReportsPdf.ReportGridView_RowCommand(Object sender, GridViewCommandEventArgs e) in E:\ArMS_Bh\ECS.ArMS\ReportsPdf.aspx.cs:line 197

***Logging ended***

Code which we are using for HTML to PDF conversion is:

public static void ExportToPDF(string readTemplate, HttpResponse response, String[] sHeaderFooter, string sReportNumber)

{

StreamReader r = File.OpenText(readTemplate);

try

{

Aspose.Pdf.License license = new Aspose.Pdf.License();

license.SetLicense(System.Web.HttpContext.Current.Server.MapPath("bin/Aspose.Pdf.lic"));

// Instantiate an object PDF class

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();

// add the section to PDF document sections collection

Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

// Create Header Section of the document

Aspose.Pdf.Generator.HeaderFooter header = new Aspose.Pdf.Generator.HeaderFooter(section);

// set the Odd header for the PDF file

section.OddHeader = header;

// Set the Even Header for the PDF file

section.EvenHeader = header;

// add the section to PDF document sections collection

Aspose.Pdf.Generator.Section section1 = pdf.Sections.Add();

// Create Footer Section of the document

Aspose.Pdf.Generator.HeaderFooter footer = new Aspose.Pdf.Generator.HeaderFooter(section1);

// set the Odd footer for the PDF file

section.OddFooter = footer;

// Set the Even footer for the PDF file

section.EvenFooter = footer;

// add the section to PDF document sections collection

Aspose.Pdf.Generator.Section section2 = pdf.Sections.Add();

Aspose.Pdf.Generator.Text txt = new Aspose.Pdf.Generator.Text(section, sHeaderFooter[0].ToString());

Aspose.Pdf.Generator.Text txtFooter = new Aspose.Pdf.Generator.Text(section1, sHeaderFooter[1].ToString());

txt.Margin.Top = 50;

txt.Margin.Left = 8;

txt.TextInfo.FontSize = 9;

txt.TextInfo.IsTrueTypeFontBold = true;

txt.TextInfo.FontName = "Arial";

txtFooter.Margin.Bottom = 5;

txtFooter.Margin.Top = 20;

txtFooter.Margin.Left = 30;

txtFooter.TextInfo.FontSize = 8;

txtFooter.TextInfo.IsTrueTypeFontBold = true;

txtFooter.TextInfo.FontName = "Arial";

// Add text to footer section of the Pdf file

footer.Paragraphs.Add(txtFooter);

// Add text to Header section of the Pdf file

header.Paragraphs.Add(txt);

//Create text paragraphs containing HTML text

Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

// enable the property to display HTML contents within their own formatting

//Start : Added the property to bind the Fontsize & Name (Rajesh.L)

text2.IsHtmlTagSupported = true;

text2.TextInfo.FontSize = 8;

text2.TextInfo.FontName = "Arial";

text2.TextInfo.IsTrueTypeFontBold = true;

text2.IfHtmlTagSupportedOverwriteHtmlFontNames = true;

text2.IfHtmlTagSupportedOverwriteHtmlFontSizes = true;

if (string.Compare(sReportNumber, "07") == 0)

{

text2.TextInfo.IsTrueTypeFontBold = false;

}

if (string.Compare(sReportNumber, "05") == 0)

{

txt.TextInfo.FontSize = 7;

txt.TextInfo.IsTrueTypeFontBold = false;

header.Margin.Right = 2;

}

else if (string.Compare(sReportNumber, "01") == 0

|| string.Compare(sReportNumber, "02") == 0

|| string.Compare(sReportNumber, "03") == 0

|| string.Compare(sReportNumber, "04") == 0

|| string.Compare(sReportNumber, "06") == 0

|| string.Compare(sReportNumber, "08") == 0

|| string.Compare(sReportNumber, "10") == 0

|| string.Compare(sReportNumber, "11") == 0

|| string.Compare(sReportNumber, "13") == 0

|| string.Compare(sReportNumber, "14") == 0

|| string.Compare(sReportNumber, "15") == 0

|| string.Compare(sReportNumber, "16") == 0

|| string.Compare(sReportNumber, "17") == 0

|| string.Compare(sReportNumber, "19") == 0

|| string.Compare(sReportNumber, "20") == 0

)

{

text2.TextInfo.FontSize = 9;

}

//End : Added the property to bind the Fontsize & Name (Rajesh.L)

//Add the text paragraphs containing HTML text to the section

section.Paragraphs.Add(text2);

response.ClearHeaders();

response.ContentType = "application/pdf";

response.Clear();

response.AppendHeader("Content-Disposition", "attachment");

r.Close();

pdf.Save("NewDoc.pdf", Apdf.SaveType.OpenInBrowser, response);

response.Close();

HttpContext.Current.ApplicationInstance.CompleteRequest();

}

#region Exceptions

catch (NotSupportedException notsupex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Not Supported Exception :", notsupex).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (UnauthorizedAccessException unauthex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template :Unauthorized access Exception :", unauthex).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (DirectoryNotFoundException direx)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Directory not found Exception :", direx).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (ArgumentNullException argnull)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Arguments Null Exception :", argnull).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (ArgumentOutOfRangeException argsoorex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Arguments Out of range Exception :", argsoorex).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (ArgumentException argex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Arguments Exception :", argex).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (PathTooLongException pathex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : IO Path Too long Exception :", pathex).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (HttpException httpex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - Template : Http Exception :", httpex).WriteLog(HttpContext.Current.User.Identity.Name);

}

catch (Exception ex)

{

new CustomExceptionHandler("ReportsPDF - ExportToPDF - : Template Read" + readTemplate, ex).WriteLog(HttpContext.Current.User.Identity.Name);

throw;

}

finally

{

wordHeaderText.Remove(0, wordHeaderText.Length);

excelHeaderText.Remove(0, wordHeaderText.Length);

headerText.Remove(0, wordHeaderText.Length);

}

#endregion

}

-----------------------------------------------------------------------------------------------

Hi Manish,


Thanks for your inquiry. While testing the scenario with Aspose.Pdf for .NET 8.5.0, I’m afraid I’m unable to reproduce the reported issue but OutOfMemory exception. I’ve logged this issue as PDFNEWNET-35966 in our bug tracking system for further investigation and resolution. We will keep you updated about the issue progress via this forum thread.

Moreover, we will appreciate if you please share a sample application to reproduce original NullReferneceException. So we will guide you accordingly.

We are sorry for the inconvenience caused.

Best Regards,

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


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