You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
The text was updated successfully, but these errors were encountered:
Are you using the latest version and with a valid license? Can you please create a post in our official support forum along with your sample file so that we can test the scenario in our environment and address it accordingly.
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?
The text was updated successfully, but these errors were encountered: