Delete all Form Fields - Any way to automate?

Community Beginner ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

In the 2020 version of Acrobat DC, is there a way to automate deleting all form fields in the PDF? I looked at Action Wizard and it doesn't look like you can use it to do this. I can't write JavaScript. Here is how I manually do this for each PDF.

  1. Open the PDF.
  2. In the PDF, select Tools > Prepare Form.
  3. In the Fields pane, change the sort order to Alphabetical order. (You can't do the next step in the default Tab order.)
  4. Select all the fields in the list by selecting the first field, hold down Shift, and then select the last field.
  5. Right-click the selection and then click Delete.
  6. Save the PDF.

I would like to repeat this process for an entire folder of files. (I am deleting "buttons" that use the form field to perform an action. If I use Redact > Remove Hidden Information and select "Form fields" and then execute, it deletes the field's entry from the PDF but leaves behind the button. When I perform the above procedure it deletes both the field and the button.) 

Any help will be appreciated!

TOPICS
Acrobat SDK and JavaScript, PDF forms

Views

443

Likes

Translate

Translate

Report

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

correct answers 1 Correct Answer

Most Valuable Participant , Mar 13, 2020 Mar 13, 2020
Have your Action execute the following JavaScript code: for (var i=this.numFields-1; i>=0; i--) { var f = this.getField(this.getNthFieldName(i)); if (f==null) continue; this.removeField(f.name); }

Likes

Translate

Translate
Most Valuable Participant ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

Have your Action execute the following JavaScript code:

 

for (var i=this.numFields-1; i>=0; i--) {
	var f = this.getField(this.getNthFieldName(i));
	if (f==null) continue;
	this.removeField(f.name);
}

Likes

Translate

Translate

Report

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 ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

Thank you so much! This will save me time.

 

I realize that this might be too much work but if it is not, I'd also like to know how to delete fields that start with the same name. For example, Search1, Search2, Search3...

Likes

Translate

Translate

Report

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
Most Valuable Participant ,
Mar 13, 2020 Mar 13, 2020

Copy link to clipboard

Copied

LATEST

Change this line:

this.removeField(f.name);

To:

if (/^Search/.test(f.name)) this.removeField(f.name);

This will remove all fields whose name starts with "Search".

Likes

Translate

Translate

Report

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