Thank you for contacting support.
I would like to request you to please try using below code snippet, along with Aspose.PDF for Java 18.2 in your environment. It extracts all the text from a PDF document as a String in the memory and you may manipulate that String as per your requirements.
// Open document
Document pdfDocument = new Document(dataDir + "Test.pdf");
// Create TextAbsorber object to extract text
TextAbsorber textAbsorber = new TextAbsorber(new TextExtractionOptions(TextExtractionOptions.TextFormattingMode.Raw));
// Accept the absorber for all the pages
// Accept the absorber for particular PDF page
// Get the extracted text
String extractedText = textAbsorber.getText();
I hope this will be helpful. Please let us know if you need any further assistance.