Skip to main content
Participant
June 5, 2017
Answered

Deleting the same field across multiple pages

  • June 5, 2017
  • 1 reply
  • 1460 views

I have a 200+page PDF that has hundreds of fields per page. The pdf is generated from an ERP system, but does not have the fields when it is created, so I run the auto detect forms feature so they can be filled out. All of the fields are created correctly with the exception of ONE! Acrobat puts the form in the wrong spot on the page.

Is there a way to remove ALL of this one field, on each of the pages of the PDF?

Since the Auto Detect feature is used the name of the field is incremented on each page, so the names are not identical.

The naming structure of the filed is "Enter Biweekly Oncall Amount" then increments as Enter Biweekly Oncall Amount_1, _2, _3 etc.

I've seen solutions for identically named fields, but the incrementing  is giving me trouble.

This topic has been closed for replies.
Correct answer try67

Sure, it's possible. Run this code from the JS Console:

var counter = 0;

for (var i=this.numFields-1; i>=0; i--) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (/^Enter Biweekly Oncall Amount/.test(f.name)) {

        this.removeField(f.name);

        counter++;

    }

}

app.alert("Deleted " + counter + " fields.",3);

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
June 5, 2017

Sure, it's possible. Run this code from the JS Console:

var counter = 0;

for (var i=this.numFields-1; i>=0; i--) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (/^Enter Biweekly Oncall Amount/.test(f.name)) {

        this.removeField(f.name);

        counter++;

    }

}

app.alert("Deleted " + counter + " fields.",3);

Participant
June 5, 2017

I must be doing something wrong.

app.alert("Deleted " + counter + " fields.",3); 

counter is not defined

1:Console:Exec

ReferenceError: counter is not defined

1:Console:Exec

undefined

try67
Community Expert
Community Expert
June 5, 2017

You need to select the whole code before executing it. Otherwise it will

only execute the current line you're on...

On Mon, Jun 5, 2017 at 10:29 PM, No1UCFfan97 <forums_noreply@adobe.com>