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

Make multiple PDFs fillable with the same fillable fields

Community Beginner ,
Jun 14, 2023 Jun 14, 2023

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

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?

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

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.

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

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;
}
}
}

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

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?

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

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.

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

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.

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

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? 

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