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

Delete all Form Fields - Any way to automate?

Explorer ,
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

Views

7.3K

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

Community Expert , 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);
}

Votes

Translate

Translate
Community Expert ,
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);
}

Votes

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
Explorer ,
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...

Votes

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 Expert ,
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".

Votes

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