Find and Replace Text in PDFs
Find and Replace is powerful programmatic text editing in PDFs with precision and flexibility. It enables precise search-and-replace in PDFs while preserving the original layout, fonts, and structure. Whether you're modernizing terminology, localizing content, or applying consistent phrasing across documents, it delivers fast, reliable results—while preserving the visual integrity of your files.
Key capabilities include:
Flexible Matching: Choose from exact, wildcard, or regex-based search
Smart Reflow: Maintain paragraph structure and alignment
Layout Preservation: Replacement text is fitted within the existing text box, with minimal adjustments to font size or spacing made only when necessary to maintain visual consistency
Customizable Options: Match case, whole words, page ranges, and more
How Find and Replace Works
Unlike basic search tools, Find and Replace is designed for structured, automated, and scalable document transformations. It uses Apryse's native PDF editing engine to find and replace text content. Page layout is recalculated dynamically, so changes are absorbed into the document without affecting visual quality or structure.
// Open a PDF document to edit
PDFDoc doc(input_path + "find-replace-test.pdf");
FindReplaceOptions options = FindReplaceOptions();
// Set some find/replace options
options.SetWholeWords(true);
options.SetMatchCase(true);
options.SetMatchMode(FindReplaceOptions::e_exact);
options.SetReflowMode(FindReplaceOptions::e_para);
options.SetAlignment(FindReplaceOptions::e_left);
// Perform a Find/Replace finding "the" with "THE INCREDIBLE"
FindReplace::FindReplaceText(doc, "the", "THE INCREDIBLE", options);
// Save the edited PDF
doc.Save(output_path + "find-replace-test-replaced.pdf", SDFDoc::e_linearized);
// Read a PDF document from a stream or pass-in a memory buffer...
FileStream istm = new FileStream(input_path + "find-replace-test.pdf", FileMode.Open, FileAccess.Read);
using (PDFDoc doc = new PDFDoc(istm))
{
FindReplaceOptions options = new FindReplaceOptions();
// Set some find/replace options
options.SetWholeWords(true);
options.SetMatchCase(true);
options.SetMatchMode(FindReplaceOptions.MatchType.e_exact);
options.SetReflowMode(FindReplaceOptions.ReflowType.e_para);
options.SetAlignment(FindReplaceOptions.HorizAlignment.e_left);
// Perform a Find/Replace finding "the" with "THE INCREDIBLE"
FindReplace.FindReplaceText(doc, "the", "THE INCREDIBLE", options);
// Save the edited PDF
doc.Save(output_path + "find-replace-test-replaced.pdf", SDFDoc.SaveOptions.e_linearized);
}Benefits of Find and Replace
Automation-Ready: Ideal for batch processing and enterprise workflows
Highly Configurable: Tailor behavior to your document structure and language rules
Reliable Engine: Built on the trusted Apryse PDF platform
For full code samples and advanced usage, visit the Find and Replace SDK Samples Page.
Last updated
Was this helpful?