Merge PDF documents into a single PDF throws ApiException

Hi,

I ran into the below exception when trying to combine multiple PDF documents into a single PDF by using PutMergeDocuments method -

Error calling PutMergeDocuments: {"ClassName":"System.ArgumentOutOfRangeException","Message":"Index was out of range. Must be non-negative and less than the size of the collection.","Data":null,"InnerException":null,"HelpURL":null,"StackTraceString":" at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)\r\n at System.Collections.Generic.List1.RemoveAt(Int32 index)\r\n at System.Collections.Generic.List1.Remove(T item)\r\n at Aspose.Imaging.Cache.\u0003.Dispose(Boolean \u0002)\r\n at System.IO.Stream.Close()\r\n at \u0002 .\u0002 ​​​\u0002()\r\n at \u0002 .Dispose(Boolean \u0002)\r\n at \u0002 .Close()\r\n at Aspose.Imaging.StreamContainer.DisposeStream()\r\n at Aspose.Imaging.StreamContainer.ReleaseManagedResources()\r\n at Aspose.Imaging.DisposableObject.\u0002(Boolean \u0002)\r\n at \u0002 .ReleaseManagedResources()\r\n at Aspose.Imaging.DisposableObject.\u0002(Boolean \u0002)\r\n at \u0005 .Process(Rectangle \u0002, Byte[] \u0003, Point \u0005, Point \b)\r\n at \u000f .Process(Rectangle \u0002, Int32[] \u0003, Point \u0005, Point \b)\r\n at \u000e .Process(Rectangle \u0002, Int32[] \u0003, Point \u0005, Point \b)\r\n at \u000e .\u0003(Rectangle \u0002, IPartialArgb32PixelLoader \u0003)\r\n at \u000e .\u0002(Rectangle \u0002, IPartialArgb32PixelLoader \u0003)\r\n at \u000e .\u0003.LoadPartialArgb32Pixels(Rectangle \u0002, IPartialArgb32PixelLoader \u0003)\r\n at \b .\u0006 ​​​​\u0002(Rectangle \u0002)\r\n at \u000e .\u0002(\u0006 ​ \u0002, IList1 \u0003, \u0003 \u0005)\r\n at \u000e .\u0002(Rectangle \u0002, \u0006 ​ \u0003, \u0002 \u0005, Int32 \b, Int32 \u0006, \u0003 \u000e)\r\n at \u000f .LoadPartialArgb32Pixels(Rectangle \u0002, IPartialArgb32PixelLoader \u0003)\r\n at \b .\u0006 ​​​​\u0002(Rectangle \u0002)\r\n at \u000e .\u0002(\u0006 ​ \u0002, IList1 \u0003, \u0003 \u0005)\r\n at \u000e .\u0002(Rectangle \u0002, \u0006 ​ \u0003, \u0002 \u0005, Int32 \b, Int32 \u0006, \u0003 \u000e)\r\n at \u0005 .\u0002 ​​​\u0002(Rectangle \u0002, IPartialArgb32PixelLoader \u0003)\r\n at Aspose.Imaging.FileFormats.Jpeg.JpegImage.\u0002(RasterImage \u0002, JpegOptions \u0003, \u0006 \u0005, Rectangle \b)\r\n at Aspose.Imaging.FileFormats.Jpeg.JpegImage.\u0002(RasterImage \u0002, Stream \u0003, JFIFData \u0005, JpegExifData \b, XmpPacketWrapper \u0006, Byte[] \u000e, JpegOptions \u000f, Rectangle \u0002 )\r\n at Aspose.Imaging.FileFormats.Jpeg.JpegImage.SaveData(Stream stream)\r\n at Aspose.Imaging.DataStreamSupporter.Save(Stream stream)\r\n at Aspose.Pdf.XImage.#=z6yfVvGO2bukV(Stream #=z90soIT0=)\r\n at Aspose.Pdf.XImage.#=z6yfVvGO2bukV()\r\n at Aspose.Pdf.XImage.get_Grayscaled()\r\n at Aspose.Pdf.Cloud.Business.ImagePresentation..ctor(XImage image, PresentationUriBuilder uriBuilder, ImageCollection imageCollection, Rectangle _rectangle, Int32 pageNumber) in C:\\ms\\src\\Aspose.PDF.Cloud\\Business\\Images\\ImagePresentation.cs:line 26\r\n at Aspose.Pdf.Cloud.Business.ImageCollection..ctor(PresentationUriBuilder uriBuilder, ImagePlacementCollection imagePlacements, Int32 pageNumber) in C:\\ms\\src\\Aspose.PDF.Cloud\\Business\\Images\\ImageCollection.cs:line 24\r\n at Aspose.Pdf.Cloud.Business.PdfPagePresentation.get_Images() in C:\\ms\\src\\Aspose.PDF.Cloud\\Business\\PdfPagePresentation.cs:line 172\r\n at Aspose.Pdf.Cloud.Business.PresentationExtension.ToDTO(PageCollection pages) in C:\\ms\\src\\Aspose.PDF.Cloud\\Business\\PresentationExtension.cs:line 53\r\n at Aspose.Pdf.Cloud.Business.PresentationExtension.ToDTO(IPdfDocumentPresentation presentation) in C:\\ms\\src\\Aspose.PDF.Cloud\\Business\\PresentationExtension.cs:line 35\r\n at Aspose.Pdf.Cloud.Business.ResponseExtension.ToResponse(IPdfDocumentPresentation presentation) in C:\\ms\\src\\Aspose.PDF.Cloud\\Business\\ResponseExtension.cs:line 23\r\n at Aspose.Pdf.Cloud.Controllers.MergeController.PutMergeDocuments(String name, MergeDocuments mergeDocuments, String storage, String folder) in C:\\ms\\src\\Aspose.PDF.Cloud\\Controllers\\MergeController.cs:line 54","RemoteStackTraceString":null,"RemoteStackIndex":0,"ExceptionMethod":"8\nThrowArgumentOutOfRangeException\nmscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.ThrowHelper\nVoid ThrowArgumentOutOfRangeException(System.ExceptionArgument, System.ExceptionResource)","HResult":-2146233086,"Source":"mscorlib","WatsonBuckets":null,"ParamName":"index","ActualValue":null}

The versions we are using are -

  1. Aspose.Cells-Cloud - v21.5.0
  2. Aspose.PDF-Cloud - v20.12.0
  3. Aspose.Words-Cloud - v21.5.0

Not sure why we see the above exception only sometimes i.e error is thrown intermittently. Any help is greatly appreciated. Thanks in advance.

@s2205

It looks like input documents related issue. However, please share your input documents along with the sample code used for PDF merging. We will try to replicate the issue and share our findings with you.