Some test text!

Loading...
Guides
Search & replace

Replacing text & images in PDFs with 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");
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

Upcoming Webinar: SDK Features Preview and Live Run-Through | July 14, 2022 at 11 am PT

PDFTron SDK

The Platform

NEW

© 2022 PDFTron Systems Inc. All rights reserved.

Privacy

Terms of Use