-
Couldn't load subscription status.
- Fork 136
Description
here is the sample code for replace text in pdf use aspose-pdf.jar, it can only replace the first page of pdf.
public static void replaceTextOnAllPages() { // Open document Document pdfDocument = new Document("source.pdf"); // Create TextAbsorber object to find all instances of the input search phrase TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("sample"); // Accept the absorber for first page of document pdfDocument.getPages().accept(textFragmentAbsorber); // Get the extracted text fragments into collection TextFragmentCollection textFragmentCollection = textFragmentAbsorber.getTextFragments(); // Loop through the fragments for (TextFragment textFragment : (Iterable<TextFragment>) textFragmentCollection) { textFragment.setText("New Pharase"); } pdfDocument.save("Updated_Text.pdf"); }
now I want to replace the text for all pages in pdf, how can I do?