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

Make multiple PDFs fillable with the same fillable fields

Community Beginner ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

I am creating PDF order forms for hundreds of customers.  The forms are all the same template and need the same fillable field.  I found an action wizard java script that previously worked but with the updated version of adobe it no longer works properly.  Is there a way to mass make PDFs fillable with the same set of fields?

TOPICS
How to , PDF , PDF forms

Views

528

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 ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

Hi @Brittany29825462yssn ,

 

I assume that you were probably using an old plug-in?

 

If yes, where did you downloaded it from?

 

Please clarify what you meant by "java script".

 

Did you mean to say that  that you have an Acrobat JavaScript (JS) script that used to work for you when invoked through the Acrobat's Action Wizard ?

 

Or are you referring to a script written in Oracle's  JAVA scripting language?

 

In any case, would you mind sharing the script, or better yet, would you be able to share a dummy PDF file of that template with no sensitive data on it?

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 ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

There's no reason a script that worked before should not work now, unless something changed about the files.

Post the code and a sample file, if possible.

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 Beginner ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

Below is the javascript that I found.  Attached is the file that I am trying to duplicate the fields.  I apologize I do not have any experience with javascript so I do not know how to trouble shoot.  I just know that last week I used this and it worked and I am trying to use it again and it does not.

 

for (var p=1; p<this.numPages; p++) {
for (var f = 0; f < numFields; f ++)
{
name = getNthFieldName(f);
type = getField(getNthFieldName(f)).type;
rect = getField(getNthFieldName(f)).rect;
fillColor = getField(getNthFieldName(f)).fillColor;
borderColor = getField(getNthFieldName(f)).borderColor;
var newField = this.addField(name, type, p, rect);
if(type = 'checkbox'){
newField.fillColor=fillColor;
newField.borderColor=borderColor;
}
}
}

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 ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

For starters, this line:

if(type = 'checkbox'){

Should be changed to:

if(type == 'checkbox'){

Also, borderColor is deprecated and should not be used. Replace it with strokeColor.

Also #2, signature fields can't be duplicated. They must have a unique name.

 

Is your ultimate goal to copy all the fields from page 1 to the other pages in the file?

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 Beginner ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

Yes.  I have multiple separate PDFs that I want the fillable fields to be in the same location.  I have an action wizard set up to add the template page to the beginning of the destination file then it runs that javascript to copy the fields on the destination file and then it deletes the template file and saves.

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 ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

Well, your code doesn't do that. It copies all the fields in the file. What you need to do is add a condition that checks the page property of the field first. If it's zero (meaning it's on page 1) then use a loop to copy it to the other pages. If not, skip it. Another issue, though, is that as you add new fields the value of numFields will change while the code is running, and that might cause some strange problems in your loop. To fix that issue you should run the for-loop in reverse, starting from numFields-1 and going down to 0.

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
New Here ,
Jan 31, 2024 Jan 31, 2024

Copy link to clipboard

Copied

Were you @try67 or @Brittany29825462yssn able to figure out how to adjust script so it would copy up to 2 signatures while copying all other fields as well? 

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
New Here ,
Feb 01, 2024 Feb 01, 2024

Copy link to clipboard

Copied

LATEST
var myDict = {};

for (var f = 0; f < this.numFields; f++) {
    var nameF = getNthFieldName(f);
    var field = getField(nameF);

    myDict[nameF] = {
        type: field.type,
        rect: field.rect,
        fillColor: field.fillColor,
        borderColor: field.borderColor
    };
}

for (var p=1; p<this.numPages; p++) {
    for (var nameF in myDict) {
        var fieldInfo = myDict[nameF];

        if(fieldInfo.type == 'signature'){
            var nameF_signature = nameF + '_new';
            var signatureField = this.addField(nameF_signature, fieldInfo.type, p, fieldInfo.rect);
        } else {
            var newField = this.addField(nameF, fieldInfo.type, p, fieldInfo.rect);
            if(fieldInfo.type == 'checkbox'){
                newField.fillColor = fieldInfo.fillColor;
                newField.borderColor = fieldInfo.borderColor;
            }
        }
    }
}

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