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

Free Support Forum - aspose.com

Error When Converting HTML to PDF: StartIndex cannot be less than zero

Hello:

I’m using Aspose PDF.Net for rendering my HTML into PDF format. For 99% of all clients, this is working 100% correctly.

However, for one file, I am receiving the following error listed below.

I realize it is probably due to invalid characters in my HTML, but how can I figure out what they are to remove them? The HTML string is quite long and I can’t see anything obvious.

I’m using version 5.1.0.0.

Thanks,
Mark Raasch


==================

StartIndex cannot be less than zero.
Parameter name: startIndex

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.ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex

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:

[ArgumentOutOfRangeException: StartIndex cannot be less than zero.
Parameter name: startIndex]
   System.Text.StringBuilder.Remove(Int32 startIndex, Int32 length) +7476507
   (Object , Int32 , Int32 ) +10
   ‡..€(String , String ) +601
   ‡..€(String ) +35
   ..€(String ) +88
   ..€(Pdf , Section , Cell , Text ,  ) +383
   ..€(Pdf , Section , Table , Cell , Text ,  , ƒ ) +821
   ..€(Pdf , Section , HeaderFooter , Table , Row , Cell , Text ,  , ƒ , Boolean ) +96
   ..€(Pdf , Section ,  ) +800
   ..€(Pdf ) +1198
   ..€( , Pdf ) +948
   Aspose.Pdf.Pdf.Save(String fileName, SaveType saveType, HttpResponse response) +351
   digiChart.OB.Interop.Interop.ibtnGenerate_Click(Object sender, EventArgs e) +1687
   System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +108
   System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +118
   System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

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

Please download and try the latest version of Aspose.Pdf for .NET v6.7. If you still face any issue, please share your HTML file / string with us with your sample code. We will look into your issue and get back to you.

Thank You & Best Regards,