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

Free Support Forum - aspose.com

Version 17.12 will not accept Page numbers to

Dim License As New Aspose.Pdf.License
License.SetLicense("\It1\IT\Automation\publish\Prerequisites\Aspose\Version 17.12\Aspose.Total.lic")

                Dim pdf As Aspose.Pdf.Document = New Aspose.Pdf.Document(Path.Combine(PDFPath, SequenceStep.Sequence.CurrentFile.GetFileNameWithoutExtension & ".pdf"))
                PDFfilename = Path.Combine(PDFPath, SequenceStep.Sequence.CurrentFile.GetFileNameWithoutExtension & ".pdf")
                While Not MyReader.EndOfData
                    Dim TextFragmentAbsorberAddress As New Aspose.Pdf.Text.TextFragmentAbsorber()
                    TextFragmentAbsorberAddress.TextSearchOptions.LimitToPageBounds = True
                    TextFragmentAbsorberAddress.TextSearchOptions.Rectangle = New Aspose.Pdf.Rectangle(Specs(0), Specs(1), Specs(2), Specs(3))
                    For Each tf As Aspose.Pdf.Text.TextFragment In TextFragmentAbsorberAddress.TextFragments
                        If Not String.IsNullOrWhiteSpace(tf.Text) Then
                            tf.Text = ""
                        End If

                End While

The above code has been working for us. The version we used was 9.9,0.0.
After I upgraded to version 17.12 the line:
pdf.Pages(1).Accept(TextFragmentAbsorberAddress) is now failing and the exception I am getting is:
{“Index was outside the bounds of the array.”}
This line of code has always worked for me.
I have to use the code above as our requirement is to clean only certain pages in the PDF document and not all pages.
Please help ASAP as it is holding up crucial release.

Shilpa Joshi


Thanks for contacting support.

Please make sure that you are using valid PDF document and latest version of the API i.e. Aspose.PDF for .NET 18.7. In case you still face any issue with latest version of the API, please share your sample PDF file with us. We will test the scenario in our environment and address it accordingly.

Hello Asad,
I figured the issue but need help resolving it. An error {“Index was outside the bounds of the array.”} occurs when no text is found in the rectangular area defined. If I use a PDF where the rectangular area has text the code above runs great but if I use a pdf where the area is blank it hits the exception {“Index was outside the bounds of the array.”}.

Is there a way to jump over the page(i).Accept and the For…each if no text found and avoid the exception,

Shilpa Joshi


Thanks for getting back to us.

It is good to know that you have figured out the cause of issue occurrence. In order to avoid this exception, you can simply surround particular code snippet with Try Catch block and leave the catch block empty inside loop. You can also log the exception somewhere if you want to. This way expected exception will be handled and iteration will keep executing with next number of page. In case of any further assistance, please feel free to let us know.