> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/core/pdf-editing/findandreplace.md).

# Find and Replace Text in PDFs

Search and replace text in PDF files while preserving the original layout. Replacement text is fitted within the existing text box, with minimal adjustments to font size or spacing made only when nece

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.

{% hint style="info" %}
This feature is available in the [PDF Editing add-on](https://apryse.com/capabilities) to Server SDK.
{% endhint %}

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

{% hint style="info" %}
**Trial mode page limit**

When in trial mode, output is limited to 10 pages. Once licensed, there is no page limit.
{% endhint %}

### 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.

{% tabs %}
{% tab title="C++" %}
{% code lineNumbers="true" %}

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

```

{% endcode %}
{% endtab %}

{% tab title="C#" %}
{% code lineNumbers="true" %}

```csharp
// 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);
}
```

{% endcode %}
{% endtab %}

{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// Open a PDF document to edit
PDFDoc doc = new PDFDoc(input_path + "find-replace-test.pdf");

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", PDFNet.SDFDoc.SaveOptions.e_linearized);
```

{% endcode %}
{% endtab %}
{% endtabs %}

### 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**](/core/get-started/samples/find-and-replace.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/core/pdf-editing/findandreplace.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
