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

Free Support Forum - aspose.com

Getting IndexoutrangeException while merging

Hi,

I am trying to merge two documents by using new aspose 19.2 evaluation version but getting below error while merging at the following line "mergedDoc.getPages().add(majorDoc.getPages()); "

code snippet :
Document majorDoc = new Document(majorDocFullPath);
Document childDoc = new Document(childDocFullPath);
Document mergedDoc = new Document();
log.info(“Before merge ::”);
mergedDoc.getPages().add(childDoc.getPages());
mergedDoc.getPages().add(majorDoc.getPages());
mergedDoc.save(outputFullPath);

Error details:
Exception in thread “main” class com.aspose.pdf.exceptions.IndexOutOfRangeException: At most 4 elements (for any collection) can be viewed in evaluation mode.
com.aspose.pdf.ADocument.lf(Unknown Source)
com.aspose.pdf.PageCollection.lf(Unknown Source)
com.aspose.pdf.PageCollection.get_Item(Unknown Source)
com.aspose.pdf.PageCollection.lI(Unknown Source)
com.aspose.pdf.PageCollection.lI(Unknown Source)
com.aspose.pdf.PageCollection.add(Unknown Source)
com.citigroup.contractuals.AsposeMerge.mergeFiles(AsposeMerge.java:59)
com.citigroup.contractuals.AsposeMerge.main(AsposeMerge.java:103)
at com.aspose.pdf.ADocument.lf(Unknown Source)
at com.aspose.pdf.PageCollection.lf(Unknown Source)
at com.aspose.pdf.PageCollection.get_Item(Unknown Source)
at com.aspose.pdf.PageCollection.lI(Unknown Source)
at com.aspose.pdf.PageCollection.lI(Unknown Source)
at com.aspose.pdf.PageCollection.add(Unknown Source)
at com.citigroup.contractuals.AsposeMerge.mergeFiles(AsposeMerge.java:59)
at com.citigroup.contractuals.AsposeMerge.main(AsposeMerge.java:103)

@kd64188

Thank you for contacting support.

You are facing evaluation version limitations. In order to test the API in its full capacity, you may apply a 30-days temporary license. You may request for temporary license on the given link and evaluate latest version of the API as per your requirements. Once you complete evaluation process, you may purchase the license to keep using APIs features. In case you face any issue, please feel free to let us know.