Some test text!

menu
search
Replace contentkeyboard_arrow_down

Replace content

To replace text or images in a PDF.

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];

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

Get the answers you need: Support

close

Free Trial

Get unlimited trial usage of PDFTron SDK to bring accurate, reliable, and fast document processing capabilities to any application or workflow.

Select a platform to get started with your free trial.

Unlimited usage. No email address required.

PDFTron Receives USD$71 Million Growth Investment Led By Silversmith Capital Partners

Learn more
close