Search and Replace in PDF. Variable Data Publishing (VDP) in PDF with PDFNet

Q: Our requirement is to replace some text (“Tray 1” ) in a fixed location with another text (“Tray 2”) in the pdf.

I have tried browsing under the PDFNet link. Most of them describes about changing the colour etc. I just want to replace the text with another text in the pdf.

A: With PDFNet v4 you could implement the required functionality (with approach similar to ElementEdit) however it could be tricky (see!topic/pdfnet-sdk/hzkDSO_n5bo).

Recently PDFTron has added a new utility class (pdftron.PDF.ContentReplacer) that could be to quickly implement text search and replace functionality - among other things.

For example:

ContentReplacer replacer = new ContentReplacer();
replacer.Add(“NAME”,“John Smith”);
replacer.Add(“QUALIFICATIONS”,“Philosophy Doctor”);
replacer.Add(“JOB_TITLE”,“Software Developer”);
replacer.Add(“ADDRESS_LINE1”,"#100 123 Software Rd");
replacer.Add(“ADDRESS_LINE2”,“Vancouver, BC”);

Would replace the given placeholders on a PDF template with variable text. The ContentReplacer does not use AcroForm and is not limited to static rectangular annotation regions.

A full sample project (C#, C++, VB, etc) can be downloaded from:

You can download the last unofficial version that includes PDF ContentReplacer using the following link(s):

Please let us know if you have any questions