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

Free Support Forum - aspose.com

Error when opening PDF file via Aspose.Pdf.Document(fileName)

I’m trying to open a template file to populate some fields before emailing the file to various recipients and I’m getting this error:

Server Error in ‘/’ Application.

Index was outside the bounds of the array.
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.IndexOutOfRangeException: Index was outside the bounds of the array.

Source Error:

Line 805: {
Line 806: string templateFilePath = HttpContext.Current.Server.MapPath("~/Forms/ProjectFeedback/ProjectFeedbackForm.pdf");
Line 807: Aspose.Pdf.Document templateFile = new Aspose.Pdf.Document(templateFilePath);
Line 808:
Line 809: FileInfo newPDF = new FileInfo(Path.GetTempFileName());

Source File: C:\Users\UserName\Documents\Visual Studio Projects\PerformanceManagement\Web~Code\ProjectFeedback\DataHelp.cs Line: 807

Stack Trace:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
?..?(Byte[] , ? ) +1990
?..?( , ? ) +791
?..?( , ? ) +3198
?..( , ?& ) +70
?.?.( , ?& ) +340
?.?.?(Int64 , ArrayList ) +393
?.?.?() +1453
?.?..ctor(Stream , String , Boolean ) +776
?.?..ctor(String ) +84
?..?(String ) +47
?.?..ctor(String ) +49
?..?(String ) +47
?..?(String ) +61
?.…ctor(String ) +60
Aspose.Pdf.Document.?(String , String ) +101
Aspose.Pdf.Document…ctor(String filename) +112
PerformanceManagement.ProjectFeedback.DataHelp.BuildPdfTemplateFile(Int32 ProjectFeedbackRequestID, Hashtable ht) in C:\Users\UserName\Documents\Visual Studio Projects\PerformanceManagement\Web~Code\ProjectFeedback\DataHelp.cs:807
PerformanceManagement.ProjectFeedback.DataHelp.SendProjectFeedbackRequestPdfFormByEmail(Int32 ProjectFeedbackRequestID) in C:\Users\UserName\Documents\Visual Studio Projects\PerformanceManagement\Web~Code\ProjectFeedback\DataHelp.cs:791
ABC.Forms.ProjectFeedback.Request.SubmitFeedback_Click(Object sender, EventArgs e) in C:\Users\UserName\Documents\Visual Studio Projects\PerformanceManagement\Web\Forms\ProjectFeedback\Request.aspx.cs:315
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.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) +5563

I’ve attached the PDF template file.

A search of the forums tell me that some Aspose products have had this issue, but fixes were dealt with via a later version. I’m currently running Aspose.PDF v7.7.0.0 which I think is the latest.

On a deadline, so promptness would be much appreciated.


Hi John,

Thanks for contacting support.

In order to test the scenario, I have downloaded the document and tried viewing it using Adobe Reader 7.0.8 and I am afraid I am getting an error message that file is damaged and cannot be viewed. The file size is 79KB. Can you please double check at your end and confirm that file was properly uploaded or, you are also getting the same error when trying to view the document in Adobe Reader.

We are sorry for this inconvenience.

Yes, the file was corrupt. I replaced it with a fresh copy and the code is working now. Sorry for the false alarm.


Hi John,

I am glad to hear that your problem is resolved. Please continue using our products and in case you encounter any issue or you have any further query, please feel free to contact.