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

Free Support Forum - aspose.com

TextFragmentAbsorber Only Getting First 4 Fragments

Hi,


I’m trying to extract all of the text from a PDF page so that I can change the text’s color with Aspose 10.6.0. I’m using the TextFragmentAbsorber, but no matter what PDF I use it’s only returning me the first 4 text fragments in its Results View - the rest of the text fragments I can see in its Non-Public Members but I can’t figure out a way of accessing them…

Here’s how I’m using TextFragmentAbsorber to extract the text:


var page = pdfDoc.Pages[pageNum];// get a page from the PDF doc
var tfa = new TextFragmentAbsorber();// create the TextFragmentAbsorber
page.Accept(tfa);
var tfc = tfa.TextFragments;// get text fragments for page

foreach (TextFragment tf in tfc)// loop through each text fragment and set it’s color to black
{
tf.TextState.ForegroundColor = Color.Black;
}


However, even though tfa.TextFragments above has a count of 13 for this particular PDF page, only its Non-Public Members contain all 13 fragments, its Result View only contains the first 4 fragments (see attached screen shot).

Am I using TextFragmentAbsorber incorrectly? Or should I be using another strategy to change the text color for this PDF page?

Thank you,
-Michael


Ah - I dug a little deeper into the IndexOfOutRange exception I was getting when trying to access the fragments in TextFragments beyond the 4th element and found, buried in the base of the exception, the message: "At most 4 elements (for any collection) can be viewed in evaluation mode."

Fair enough - but a little heads up in the details or documentation for TextFragmentAbsorber.TextFragments would have saved me a lot of time and headache.


-Michael

Hi there,

Thanks for your considering Aspose. Please note Aspose.Pdf evaluation version has two limitations, evaluation watermark and at most four elements of any collection can be viewed. Please make a request for 30 days temporary license and apply license to evaluate our product without any limitation. Hopefully your issue will be resolved.

Please feel free to contact us for any further assistance.

Best Regards,