ASPOSE rendering pdf merge blank or with index out of array

We seem to be having issues with merging PDFS. Since updateing the control we get the following 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:

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:

[IndexOutOfRangeException: Index was outside the bounds of the array.]
   Aspose.Pdf.Kit.PdfFileEditor.Concatenate(Stream[] inputStreams, Stream outputStream)
   Document_ViewPDF.MergePDFs(String strFileNames) +700
  Document_ViewPDF.BuildPDF(Boolean blnDisplay, String strID, String strTemplateID, String strClientID) +2516
   Document_ViewPDF.Page_Load(Object sender, EventArgs e) +880
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +35
   System.Web.UI.Page.ProcessRequestMain() +750

Now beforethe update i would render blank. Here is the code excuted:

Private Function MergePDFs(ByVal strFileNames As String) As String

Dim myDefault As New _Default

Dim strRet As String = myDefault.CreateUniqueName()

Dim arrPdfs() As String = strFileNames.Split("~")

If arrPdfs.Length = 2 Then

Dim strDestPath As String = Server.MapPath("output\") & strRet & ".doc.pdf"

Try

System.IO.File.Copy(arrPdfs(0), strDestPath)

Catch ex As Exception

End Try

Else

Dim strDestPath As String = Server.MapPath("output\") & strRet & ".doc.pdf"

'Creating output stream object that will store the resulting PDF file after appending

Dim outputStream As System.IO.FileStream = New System.IO.FileStream(strDestPath, System.IO.FileMode.Create, IO.FileAccess.Write)

Dim inStreams() As System.IO.Stream

ReDim inStreams(0)

'Instantiating PdfFileEditor object

Dim pdfEditor As Aspose.Pdf.Kit.PdfFileEditor = New Aspose.Pdf.Kit.PdfFileEditor

Dim license As Aspose.Pdf.Kit.License = New Aspose.Pdf.Kit.License

license.SetLicense("Aspose.Total.lic")

Dim i As Int16

Dim blnGotFirst As Boolean = False

For i = 0 To arrPdfs.Length - 1

If arrPdfs(i).Length > 0 Then

If System.IO.File.Exists(arrPdfs(i)) = True Then

If blnGotFirst = True Then

ReDim Preserve inStreams(inStreams.Length)

End If

blnGotFirst = True

Dim inStream1 As System.IO.FileStream = New System.IO.FileStream(arrPdfs(i), IO.FileMode.Open, IO.FileAccess.Read)

inStreams(inStreams.Length - 1) = inStream1

''inStream1.Close()

End If

End If

Next

'Call Concatenate method of PdfFileEditor object to concatenate all input streams into a single output stream

pdfEditor.Concatenate(inStreams, outputStream)

outputStream.Close()

End If

Return strRet

End Function

This is running on Windows 2003 R2 SP2. This code works fine on windows xp sp2. I have checked security logs and do not see any issues. What could be causing this, where canI look, this is driving us nuts. Please advise...

We are running 2.4.2.0 of the Aspose.Pdf.Kit.

Thank you,

Gavin Duffy

Hi,

Thank you for considering Aspose.

I am not been able to reproduce the error. I have tried this code on both Windows Xp SP2 and Windows Server 2003 SP1 wuth v2.4.2.0. Please send your Pdf File that is causing this problem, from the stack trace I can’t get the whole error details.

Thanks.

Adeel Ahmad
Support Developer
Aspose Changsha Team
http://www.aspose.com/Wiki/default.aspx/Aspose.Corporate/ContactChangsha.html

Can you give me your email. I cannot make these PDFs public.

Please send your PDF files by using any of the methods mentioned in the following article:

Both Adeel and I can’t reproduce this error. I think you should check if the inStreams is correct.