Skip to main content
Inspiring
August 28, 2020
Question

Create form fields automatically

  • August 28, 2020
  • 2 replies
  • 1397 views

Hi,

 

I've got the following situation: I have an MS Excel file that I print/save as an Adobe PDF. In that PDF I need three signature fields. So I open that PDF and create the form and place the three fields by scratch.

 

The pity: I have about 300 Excel files per month that I have to handle like that.

 

Is there any possibility to handle that automatically?

 

Thanks

L

This topic has been closed for replies.

2 replies

Lukas5E13Author
Inspiring
August 31, 2020

Now I'm at work and do have a few problems.

First: I cannot open the console. Ctrl + J does not work. I found in the web that Ctrl + J generally does not work with Adobe Standard...

Second: I createt a subfolder-path "Privileged\DC\Javascripts" in the path "C:\Users\<username>\AppData\Roaming\Adobe\Acrobat\" and put there the following js-file for testing, named "buttons.js":

app.addToolButton({
cName: "Open Console",
cLabel: "Cons",
cExec: "openConsole()",
cTooltext: "open console",
cEnable: true,
nPos: -1
});

function openConsole(){
console.show();
};

How can I see whether it worked or not? Where is the toolbar the button is supposed to be?

Third: Even if I change the content of the js-file only to "console.show();", nothing happened when I start Adobe.

Lukas5E13Author
Inspiring
August 31, 2020

Edit:

Second: Adobe Reader does find the js-file and the button! But: In Adobe Acrobat Standard DC I don't see the "Add-On Tools"-toolbar. It seems like I have no possibility to see the toolbar!

 

Any idea?

try67
Community Expert
Community Expert
August 31, 2020

Now I reached to get the console in Adobe Standard. If I put "app.getPath("user","javascript");" I will get the following

GeneralError: Vorgang fehlgeschlagen.
App.getPath:1:Console undefined:Exec
2

 

What does that mean?


That the path is not defined. Replace "user" with "app" in the code and try again.

try67
Community Expert
Community Expert
August 28, 2020

Do they always need to be at the same spot on the same page? If so, then yes, it's possible to create a script that will add those fields. If you have Acrobat Pro then it's even possible to run this script as a part of an Action on multiple files...

Lukas5E13Author
Inspiring
August 29, 2020

Yes! How do I do this? I never used scripts in Acrobat before. I only have Acrobat Standard.

try67
Community Expert
Community Expert
August 29, 2020

(Edited)

 

OK, then the next step is to identify the field's location. To do that create the field manually and then open the JS-Console and run the following command (let's say it's called "Sig1"):

 

console.println(this.getField("Sig1").rect);

 

This will print out a bunch of numbers, which represent the locations of those fields. This information can be used in the addField method to create the field, like this:

 

this.addField("Sig1", "signature", 0, [149.29299926757812,733.9965209960938,396.62530517578125,717.973876953125]);

 

The numbers at the end are the ones you need to insert. The first parameter is the field name, the second is its type and the third is the page number (0 being the first page). That's it, pretty much. You can run this code from the Console itself, or even from a button or a menu item (although the latter will require adding a bit more code and placing it in a .js file in a specific folder on the computer).