> 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/ios/editing-page-content/replace.md).

# Replacing text & images in PDFs on iOS

Learn how to replace text or images in a PDF with this full code sample using pdftron.PDF.ContentReplacer. Enhance your PDF editing skills today! The Apryse iOS SDK streamlines secure document process

To find text or images and replace it in a PDF.

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

```objc
PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
PTContentReplacer *replacer = [[PTContentReplacer alloc] init];
PTPage *page = [doc GetPage: 1];

// replace an image on the page
PTPDFRect * target_region = [page GetMediaBox];
PTImage *img = [PTImage Create: [doc GetSDFDoc] filename: imagename];
[replacer AddImage: target_region replacement_image: [img GetSDFObj]];

// replace a text placeholder
[replacer AddString: @"NAME" replacement_text: @"John Smith"];

// replace text in a given region
NSString* text = @"hello world";
[replacer AddText: target_region replacement_text: text];
[replacer Process: page];
```

{% endcode %}
{% endtab %}

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

```swift
let doc: PTPDFDoc! = PTPDFDoc(filepath: filename)
let replacer: PTContentReplacer = PTContentReplacer()
let page: PTPage = doc.getPage(1)

// replace an image on the page
let target_region: PTPDFRect = page.getMediaBox()
let img: PTImage = PTImage.create(doc.getSDFDoc(), filename: imagename)
replacer.addImage(target_region, replacement_image: img.getSDFObj())

// replace a text placeholder
replacer.add("NAME", replacement_text: "John Smith")

// replace text in a given region
let text: String = "hello world";
replacer.addText(target_region, replacement_text: text)
replacer.process(page)
```

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

[Replace PDF text or images](/ios/get-started/samples.md#contentreplacer) Full code sample which shows how to use pdftron.PDF.ContentReplacer to search and replace text strings and images in existing PDF (e.g. business cards and other PDF templates).


---

# 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/ios/editing-page-content/replace.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.
