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 https://groups.google.com/forum/#!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”);
replacer.Add(“PHONE_OFFICE”,“604-730-8111”);
replacer.Add(“PHONE_MOBILE”,“604-765-4321”);
replacer.Add(“EMAIL","info@pdftron.com”);
replacer.Add(“WEBSITE_URL”,“http://www.pdftron.com”);
replacer.Process(doc.GetPage(1));

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:
http://www.pdftron.com/pdfnet/samplecode/data/PDFContentReplacer.zip

You can download the last unofficial version that includes PDF ContentReplacer using the following link(s):
http://www.pdftron.com/IDR49Z9-B31B/PDFNet.zip
http://www.pdftron.com/IDR49Z9-B31B/PDFNetDotNet4.zip
http://www.pdftron.com/IDR49Z9-B31B/PDFNet64DotNet4.zip

Please let us know if you have any questions