Text Find and Replace
using IronPdf;

// Using an existing PDF
var pdf = PdfDocument.FromFile("sample.pdf");

// Parameters
const int pageIndex = 1;
const string oldText = ".NET 6"; // Old text to remove
const string newText = ".NET 7"; // New text to add

// Replace Text on Page
pdf.ReplaceTextOnPage(pageIndex, oldText, newText);

// Save your new PDF
pdf.SaveAs("new_sample.pdf");
NuGet Download
PM > Install-Package IronPdf
Text Find and Replace

Text Find and Replace

You can find and replace text within a PDF using IronPDF's Replace.

This code demonstrates how to replace text in a PDF file using the IronPDF library in C#. First, ensure you have the IronPDF library installed via NuGet. The code loads an existing PDF through the FromFile method, replaces text on the specified page using ReplaceTextOnPage, and saves the result as a new PDF file. The page number, text to replace, and new text need to be specified. Finally, the changes are saved with SaveAs, and a message is printed to confirm the operation is complete.

Learn to Find & Replace Text in PDFs with IronPDF
View on GitHub

Ready to Get Started?

Nuget Downloads 22,024,882Version:2026.11just released