Have you ever needed to replace text in a PDF, but you didn’t have the source files? What about replacing the same bit of text on 50, 100, or 150 pages of the PDF?
If the text is small and simple (like a change to the copyright year, for example), then you could do worse than using Acrobat Pro’s built-in redact feature.
The redact feature is intended to find and delete text from a document. But the feature allows you to add new text to the place you just deleted text from. Hey, that sounds like find and replace to me.
This trick is really best when the text is standing alone, like in a header or footer, rather than in the middle of a paragraph. Watch this 5 minute video and let me know if it’s helpful. And I apologize in advance for how small/blurry the video is!
I have also found code in c# and vb.net for searching and replacing text in all pdf pages from the page below:
http://www.aspose.com/docs/display/pdfnet/Replace+Text+in+all+pages+of+a+PDF+Document
Here is the code:
The following code snippet shows you how to replace text in all pages of PDF document.
[C#]
//open document
Document pdfDocument = new Document(“input.pdf”);
//create TextAbsorber object to find all instances of the input search phrase
TextFragmentAbsorbertextFragmentAbsorber = new TextFragmentAbsorber(“Figure”);
//accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber);
//get the extracted text fragments
TextFragmentCollectiontextFragmentCollection = textFragmentAbsorber.TextFragments;
//loop through the fragments
foreach (TextFragmenttextFragment in textFragmentCollection)
{
//update text and other properties
textFragment.Text = “New Phrase”;
textFragment.TextState.Font = FontRepository.FindFont(“Verdana”);
textFragment.TextState.FontSize = 22;
textFragment.TextState.ForegroundColor =Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue);
textFragment.TextState.BackgroundColor =Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green);
}
pdfDocument.Save(“output.pdf”);
[VB.NET]
‘open document
Dim pdfDocument As New Document(“input.pdf”)
‘createTextAbsorber object to find all instances of the input search phrase
Dim textFragmentAbsorber As New TextFragmentAbsorber(“Figure”)
‘accept the absorber for all the pages
pdfDocument.Pages.Accept(textFragmentAbsorber)
‘get the extracted text fragments
Dim textFragmentCollection As TextFragmentCollection = textFragmentAbsorber.TextFragments
‘loop through the fragments
For Each textFragment As TextFragment In textFragmentCollection
‘update text and other properties
textFragment.Text = “New Phrase”
textFragment.TextState.Font = FontRepository.FindFont(“Verdana”)
textFragment.TextState.FontSize = 22
textFragment.TextState.ForegroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Blue)
textFragment.TextState.BackgroundColor = Aspose.Pdf.Color.FromRgb(System.Drawing.Color.Green)
Next TextFragment
pdfDocument.Save(“output.pdf”)
I hope this will be helpful for many users also.
Wow, thanks for that, Shamishta.