TextFragmentAbsorber tfa = new TextFragmentAbsorber("Preclinical safety data.*6\\.", new TextSearchOptions(true));pdfDocument.getPages().accept(tfa);
Hi Sujit,
I am working on testing the scenario in my environment and will get back to you soon.
Hi Nayyer,
Hi Sujith,
Thanks for your patience.
I have been trying to test the scenario using code lines you have shared earlier but I am afraid its not returning the file contents. Can you please share the code snippet which you are using, so that we can test the scenario in our environment. We are sorry for this inconvenience.
[Java]
// Open a document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("c:/pdftest/HTML_to_PDFoutput (1).pdf");
// Create TextAbsorber object to find all instances of the input search phrase
com.aspose.pdf.TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(
"(?i)Preclinical safety data *6\\.",
new com.aspose.pdf.TextSearchOptions(true)
);
// Set text search option to specify regular expression usage
textFragmentAbsorber.setTextSearchOptions(new com.aspose.pdf.TextSearchOptions(true));
// Accept the absorber for the pages of the document
pdfDocument.getPages().accept(textFragmentAbsorber);
// Get the extracted text fragments into collection
com.aspose.pdf.TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments();
// Loop through the fragments
for (com.aspose.pdf.TextFragment textFragment : textFragmentCollection) {
System.out.println("Text: " + textFragment.getText());
System.out.println("Page Number: " + textFragment.getPage().getNumber());
}