Some test text!

Replace contentkeyboard_arrow_down

Replacing text & images in PDFs in Go

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

doc := NewPDFDoc(filename)
replacer := NewContentReplacer()
page := doc.GetPage(1)

// replace an image on the page
targetRegion := page.GetMediaBox()
img := ImageCreate(doc, imagename)
replacer.AddImage(targetRegion, img.GetSDFObj())

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

// replace text in a given region
replacer.AddText(targetRegion, "Hello World");

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


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.