Some test text!

menu
search
Replace contentkeyboard_arrow_down

Replace content

To replace text or images in a PDF.

PDFDoc doc = new PDFDoc(filename);
ContentReplacer replacer = new ContentReplacer();
Page page = doc.getPage(1);

// replace an image on the page
Rect target_region = page.GetMediaBox();
Image img = Image.create(doc, imagename);
replacer.addImage(target_region, img.getSDFObj());

// replace a text placeholder
replacer.addString("NAME", "John Smith");

// replace text in a given region
String text = "hello world";
replacer.addText(target_region, 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