Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
3

How to do a Find and Replace of a text word with a form field?

Community Beginner ,
May 20, 2024 May 20, 2024

I want to have a form field where user enters their Company Name and then throughout a long/large doc. the word Company is replaced with the same form field, so it populates with their company name throughout the doc.  Please help me learn if this is possible/how do it, so I don't have to manually change over 200 words to a form field... Thanks!

TOPICS
How to , Modern Acrobat , PDF , PDF forms
1.0K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2024 May 20, 2024

In every location where the company name appears, place a form field with the name "CompanyName". Make sure all form fields have the same name. 

This should help:

https://www.pdfscripting.com/public/Editing-Fields-Properties.cfm

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2024 May 20, 2024

Thanks Thom - I was looking for a way to replace the text with a form field in a find/replace way - so that I do not have to place a form field with the name manually in 200 places... is that possible? Or do I have to insert each field manually?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2024 May 20, 2024

If that text is unique you can use a script to find all instances of it and place a text field over them. It's not a trivial task, though.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 20, 2024 May 20, 2024

OK thank you I'll look into that.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2024 May 20, 2024
LATEST

To start this process, open the redaction tool and have it search for the word sequence that marks the company name location. Do not complete the redact process. The redaction search will place a redact annot over the locations. Look through to see if they are correct.  The next step is to write a script that replaces the redact annots with form fields. 

Here's a simple one that you can run from the console window (Ctrl-J):

 

this.getAnnots.forEach(function(a){this.addField("CompanyName","text",a.page,a.rect);a.destroy();});

 

There are many things this script does not account for, such as page rotation, and it doesn't set any of the important field properties. 

For example, the field fill color should be a solid white to cover the existing text. And the rectangle should be expanded to accomodate the proper text size, which also isn't set.

 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines