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

Free Support Forum - aspose.com

TextAbsorber with Rectangle generates incomprehensible failure

I am reading a PDF page by page but on page 69 of the PDF attachment that generates an error message "Index was outside the bounds of the array" occurs.

This does not make sense that an error occurs only on page 69 and not in others, because the coordinates of the rectangle are the same as always.

Below is a snippet of code reading:

for (int page = PaginaInicial; page <= PaginaFinal; page++)
{
TextAbsorber textAbsorber = new TextAbsorber();
textAbsorber.TextSearchOptions.LimitToPageBounds = true;
textAbsorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(0, 0, 300, 500);
pdfDocument.Pages[page].Accept(textAbsorber); //<=== ERROR IN PAGE nr. 69
pg += textAbsorber.Text;
}

Hi Maria,


Thanks for contacting support.

I have tested the scenario using following code snippet with Aspose.Pdf for .NET 9.4.0 and I am unable to notice any issue. The text is properly being extracted from PDF file. For your reference, I have also attached the resultant TXT file containing extracted contents. Can you please try using the latest release and in case you encounter any issue, please share some details regarding your working environment. We are sorry for this inconvenience.

[C#]

Document doc = new Document(“c:/pdftest/TRT_22-07-2014.pdf”);<o:p></o:p>

String pg="";

for (int page = 1; page <= doc.Pages.Count; page++)

{

Console.WriteLine("Current Page count = " +page);

TextAbsorber textAbsorber = new TextAbsorber();

textAbsorber.TextSearchOptions.LimitToPageBounds = true;

textAbsorber.TextSearchOptions.Rectangle = new Aspose.Pdf.Rectangle(0, 0, 300, 500);

doc.Pages[page].Accept(textAbsorber); //<=== ERROR IN PAGE nr. 69

pg += textAbsorber.Text;

}

File.WriteAllText("c:/pdftest/ExtractedText_TRT_22-07-2014.txt", pg);

Thank you,

I tested with version 9.4.0 and the problem disappeared.

Att,

Hi Maria,


Thanks for the acknowledgement.

We are glad to hear that your problem is resolved with latest release of Aspose.Pdf for .NET. Please continue using our API and in the event of any further query, please feel free to contact.