Copy link to clipboard
Copied
After a migration from win7 from win10, my team do not know how to execute the script anymore. Here is the script I want to execute, it should append another PDF to the end of document and send a mail (I did not write it) : https://justpaste.it/61gxj .
From what I understand from google, I have to put this script in C:\Users\UserName\AppData\Roaming\Adobe\Acrobat\Privileged\10.0\JavaScripts to be able to execute trusted methods/functions. Then, how do I actually use this function ? Is the path correct ? Thank you for your help, I'm really new to this.
Edit :
app.getPath("app","javascript"); returns /C/Program Files (x86)/Adobe/Acrobat DC/Acrobat/JavaScripts so I added my script there
Copy link to clipboard
Copied
Do you use the correct syntax for the path?
Copy link to clipboard
Copied
I use :
var iconPath = "C:\Program Files (x86)\Adobe\Acrobat DC\Acrobat\Javascripts\bcs.jpg";
var myDoc = app.newDoc();
myDoc.importIcon("bcsIcon", iconPath, 0);
When I copypaste it into the file browser, it opens the icon correctly so I guess it works
Copy link to clipboard
Copied
Look at try67's first comment about the format of the path. You are using Windows syntax for the path, which will not work in an Acrobat JavaScript. You need to use Adobe's device independent format.
Copy link to clipboard
Copied
oh right ! thank you, it's corrected
And god damn this is complicated... i now have an error in
app.addToolButton({
cName: "BCSadd",
oIcon: oIcon,
cLabel: "Finish PR",
cEnable: "event.rc = (app.doc != null);",
cExec: "BCSadd();",
nPos: 0
});
The arrow is on nPos: 0 , but I guess it can be anywhere in the function.
Would it be possible that this fail because the function BCSadd defined after is not correctly called ? It is written under the script : Imgur: The magic of the Internet
Copy link to clipboard
Copied
I think the issue is that you have a function named BCSadd as well a menu item with that name. Try changing one of them...
And yes, this is complicated stuff, which is why it's very important to read the documentation carefully and keep an eye on the small details and the error messages you're getting.
Copy link to clipboard
Copied
PS. In the future, please post the error message as text, in full, not as an image.
Copy link to clipboard
Copied
Does it work when you remove following line?
oIcon: oIcon,
Have your script worked under Windows 7?
Copy link to clipboard
Copied
And the error is?
Copy link to clipboard
Copied
try67​ you were right, I tried changing the function's name and restarting everything, but I get :
main()
Exception in line 17 of function main<, script Folder-Level:App:config.js
GeneralError: Operation failed.
App.addToolButton:17:Console undefined:Exec
undefined
with the following code :
app.addToolButton({
cName: "BCSadd",
oIcon: oIcon,
cLabel: "Finish PR",
cEnable: "event.rc = (app.doc != null);",
cExec: "BCSaddFunction();",
nPos: 0
});
(I tried removing the Icon line but it still trigger the error)
So I guess this does not see the BCSaddFunction, but as you can see here : Imgur: The magic of the Internet The function exists 😕 Do you have an idea ?
Copy link to clipboard
Copied
Try narrowing it down. Remove all other code except for the addToolButton command. Does it still not work?
This code worked fine for me:
app.addToolButton({
cName: "BCSadd",
cLabel: "Finish PR",
cEnable: "event.rc = (app.doc != null);",
cExec: "BCSaddFunction();",
nPos: 0
});
Edit: Fixed wrong method name...