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

Rename the fields in the interactive PDF

New Here ,
Jun 12, 2016 Jun 12, 2016

I did create an interactive pdf in indesign

I did open the document with acrobat and fill the fields.

now I did dublicate the page to fill the fields with new informations

because the fields have the same name, the new informations will be filled in both pages and I lose

the informations in page1.

now renaming 100 fields is a time consuming.

how can I rename the fields with a script?

TOPICS
Acrobat SDK and JavaScript , Windows
2.3K
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

correct answers 1 Correct answer

Community Expert , Jun 13, 2016 Jun 13, 2016

That doesn't do anything. It will not error out but it will also not rename the fields. The "name" property is read-only.

If after running this code you run this command it will return null: this.getField("field19")

Translate
Community Expert ,
Jun 12, 2016 Jun 12, 2016

It's not possible to rename fields using a script. It's only possible to re-create the fields using the new name.

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 ,
Jun 13, 2016 Jun 13, 2016

I did try this

1. select all fields

2. Ctrl + i

3. in the action section I did type:

function rename()

{

    for(i=19; i<=102; i++) {

        var fields = this.getField("Date" + " " + i);

        fields.name = "field" + i;

    }

}

the result I want is:

befor renaming    Date 19.

after renaming     field 19.

I am not a master in programming but the idea is:

with a loop access the field name propertie and change it

I don't know, maybe this will give a hint .... or not. !

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 13, 2016 Jun 13, 2016

That doesn't do anything. It will not error out but it will also not rename the fields. The "name" property is read-only.

If after running this code you run this command it will return null: this.getField("field19")

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 13, 2016 Jun 13, 2016

As was stated before, you cannot rename fields programatically using JavaScript.

In order to get something close to a rename function, you need to recreate a new field using the old field properties (and of course using a new name and not the old name). The problem here is that you cannot read out all the properties that you can set via the user interface (or via code) when using JavaScript. Things like scripts associated with a field (validation, formatting, calculation, button up/down, ...) can only be set, and not read from a field. That means that your new fields will not have any scripts (or more general, any action) that were associate with the old fields.

To create such an "almost complete" copy of the old field, you would need to copy all the field's properties. you can get a list of these in the SDK documentation: Acrobat DC SDK Documentation - Field properties

What makes this process a bit complex is that you have to distinguish between different field types and what properties they support.

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 ,
Mar 02, 2017 Mar 02, 2017
LATEST

Hi

I could change a field color via javascript

var f = this.getField('fieldName');

f.fillColor = ["RGB",1,0.66,0.75];

But!

var f = this.getField('fieldName');

f.name = 'fieldName' + '#';

will not work. because "as you did say" the "name" property is read only.

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 13, 2016 Jun 13, 2016

Hi.

Here is a workaround:

Copy these 100 fields and paste them in a blank PDF twice as large as the original.

Select all field, right-clic and "Create multiple copy". Choose 1 more vertically or horizontally.

This will rename all field as 2 different sets.

Then copy-paste back the first set of fields on page 1 and the second set on page 2 in the original PDF.


Acrobate du PDF, InDesigner et Photoshopographe
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 13, 2016 Jun 13, 2016

You can use a template page for this.

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