Find and Replace Text in PDFs

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!

Tags: ,

2 Responses to “Find and Replace Text in PDFs”

  1. Shamishta
    October 10, 2013 at 3:27 am #

    I have also found code in c# and for searching and replacing text in all pdf pages from the page below:

    Here is the code:

    The following code snippet shows you how to replace text in all pages of PDF document.


    //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
    //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);



    ‘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
    ‘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

    I hope this will be helpful for many users also.

Leave a Reply

Subscribe without commenting