How to replace text elements within a PDF file with new content?


I need to replace certain text elements within a PDF file with new
content. Specifically, I will have a PDF file with placeholders in the
text e.g. $NAME and I want to replace them with actual values. The
process is similar to a mail merge. The PDF is for printing, so it is
important that the layering, colour models etc are preserved.

You can use PDFNet SDK ( to replace placeholders
on given page with new values.

There are couple of ways this can be implemented using PDFNet:

a) using AcroForms.
· You could use Acrobat (or some other PDF desktop software) to
create PDF templates that need to be filled out with variable text.
The fields can be created on top of any PDF document and you can
assign various properties (such as field name, border, etc).
· Once you have a PDF form, you can programmatically fill it out as
illustrated in the following samples:

b) by editing static page content.
· In this case you would locate the replacement text by reading
‘PDF.Elements’ from the page using ElementReader class (for an
example, please see
· Once you find the text you can replace it with new content as
illustrated in ElementEdit sample (
samplecode.html#ElementEdit). This sample shows how to replace text
color, but you can use the same approach to replace text content, or
even to replace the text with non-textual information (e.g. a new
image element).