Replacing text & images in PDFs on iOS

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

1PTPDFDoc *doc = [[PTPDFDoc alloc] initWithFilepath: filename];
2PTContentReplacer *replacer = [[PTContentReplacer alloc] init];
3PTPage *page = [doc GetPage: 1];
4
5// replace an image on the page
6PTPDFRect * target_region = [page GetMediaBox];
7PTImage *img = [PTImage Create: [doc GetSDFDoc] filename: imagename];
8[replacer AddImage: target_region replacement_image: [img GetSDFObj]];
9
10// replace a text placeholder
11[replacer AddString: @"NAME" replacement_text: @"John Smith"];
12
13// replace text in a given region
14NSString* text = @"hello world";
15[replacer AddText: target_region replacement_text: text];
16[replacer Process: page];

Replace PDF text or images
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).

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales