TextExtractUtils Return Before Index String and Now Index String

public static String RectTextSearch(ElementReader reader, Rect pos,int index) throws PDFNetException
{
    Element element;
    String srch_str = new String();

    while ((element = reader.next())!=null)
    {
        switch (element.getType())
        {
            case Element.e_text:
            {
                Rect bbox=element.getBBox();
                if (bbox == null) continue;
                if(bbox.intersectRect(bbox, pos))
                {
                    String arr = element.getTextString();
                    srch_str += arr;
                    //srch_str += "\n"; // add a new line?

                    System.out.println("Links to : text - "+srch_str +" pos :-- "+ pos+" index : -- "+index);
                }
                break;
            }
           
            case Element.e_form: // Process form XObjects
            {
                reader.formBegin();
                srch_str+=RectTextSearch(reader, pos,index);
                System.out.println("Links to : form - "+srch_str);
                reader.end();
                break;
            }
        }
    }
    System.out.println("Links to : return - "+srch_str +" index : "+index);
    return srch_str;

}

Why return to the old text messages come with new text messages.

141541.png

Hi, it is not clear what the issue is you are having. Please clearly state what behaviour/result you expected to get.