Free Support Forum - aspose.com

About getting text from PDF

i have tried the following code , but the context of the output is wrong ,

it only extracts the first row(not complete) of every page in PDF.

thankyou


TextAbsorber textAbsorber = new TextAbsorber();
// Accept the absorber for all the pages
pdfDocument.getPages().accept(textAbsorber);
// Get the extracted text
String extractedText = textAbsorber.getText();
// Create a writer and open the file
java.io.FileWriter writer = new java.io.FileWriter(new java.io.File(“C:\oliver\test\Aspose2.txt”));
writer.write(extractedText);
// Write a line of text to the file
// tw.WriteLine(extractedText);
// Close the stream
writer.close();

Hello Cheng,


Thanks for contacting support.

I have checked the scenario with sample PDF document while using Aspose.Pdf for Java 17.5 and was unable to observe the issue. Would you please share your input document so that we can try to replicate the issue in our environment and address it accordingly.


Best Regards,