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

Create form fields automatically

Explorer ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

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

TOPICS
Create PDFs , PDF forms

Views

622

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 ,
Aug 28, 2020 Aug 28, 2020

Copy link to clipboard

Copied

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...

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
Explorer ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

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

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 ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

(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).

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
Explorer ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

Thanks a lot! But where do I find the Java Script Console? 

 

Actually the best would be to have a menu item (or at least a shortcut?). Could you help me to do this?

 

Thanks!

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 ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

Hi,

 

JavaScript console - Ctrl+J (or Cmd+j mac).

 

Regards

 

Malcolm

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
Explorer ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

Hi,
 
I only have Acrobat Standard at work, so I'm not able to test this stuff right now. But I've found that I have to write a js-file that I have to place in the user-folder ...Javascripts.
 
In this js-file I have to define a function that adds the requested fields, no problem. Further I have to use the app.addToolButton method to create the button.
 
So is the following my whole js-file that I need?
 
app.addToolButton({
cName: "Place Sign. Fields",
cLabel: "Sign",
cExec: "placeSigFields()",
cTooltext: "place signature fields",
cEnable: true
nPos: -1
})
 
function placeSigFields() {
this.addField("Signature 1", "signature",0,[149.0,396.0]);
this.addField("Signature 2", "signature",0,[149.0,450.0]);
}
 
Best

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 ,
Aug 29, 2020 Aug 29, 2020

Copy link to clipboard

Copied

Yes, except for the fourth parameter (rect) of the addField method. That array must contain four numbers, not two.

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
Explorer ,
Aug 30, 2020 Aug 30, 2020

Copy link to clipboard

Copied

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.

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
Explorer ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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?

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
Explorer ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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?

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

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

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
Explorer ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

I don't have access to the app-folder (no Admin permissions), so I have to use the user-path.

I use Adobe Acrobat Standard DC Verison 2015.006 -> which path is the right one?

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

You should try the path you found. If it doesn't exist then you can create it yourself.

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
Explorer ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

Solution: It was "Privileged\2015\Javascripts" instead of "Privileged\DC\Javascripts"

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 ,
Aug 31, 2020 Aug 31, 2020

Copy link to clipboard

Copied

LATEST

Thanks for posting what worked for you! This could help others in the future...

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