Exception while searching text in multiple pdf at the same time

System.IndexOutOfRangeException: Index was outside the bounds of the array. exception occurs when I searching text in multiple files at the same time but when I execute one task at a time there are no exceptions.

These files are throwing an exception:
pdf_files.zip (6.1 MB)

Aspose.PDF 20.8.0 version, .NETStandard 2.1

Code snippet:

static void Main(string[] args)
		License license = new License();
		var pdfFiles = Directory.GetFiles("C:\\directory\\to\\the\\files");

		var documents = new List<Document>();
		foreach (var pdfPath in pdfFiles)
			Console.WriteLine($"Create document {pdfPath}");
			documents.Add(new Document(pdfPath));

		// int maxConcurrentTasks = 1; //no exception
		int maxConcurrentTasks = 10; //exception

		Console.WriteLine("Start searching");
		Parallel.ForEach(documents, new ParallelOptions{ MaxDegreeOfParallelism = maxConcurrentTasks },document => scan(document));
	static void scan(Document doc)
			foreach (Page actualPage in doc.Pages)
				TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("dummy_regex")
					TextSearchOptions = { IsRegularExpressionUsed = true }
		catch (Exception e)
			Console.WriteLine($"Exception occured {doc.FileName}");



We still need to investigate the feasiblity of processing PDF document in Parallel.ForEach() and for this purpose, we have logged a ticket as PDFNET-48643 in our issue tracking system. We have recorded all details against your case along with the ticket and will investigate them further. We will let you know as soon as logged ticket is resolved. Please have patience and give us some time.

We are sorry for the inconvenience.