Copy link to clipboard
Copied
I have a javascript that I used with Adobe Acrobat Pro 9. Adobe Acrobat 11 was installed on my computer and my I do not know how to get my javascript working. Can someone help me please.
It can be a non-visible character. Delete the first lines and re-enter the code.
Info: the parameter cExec is incorrect.
Copy link to clipboard
Copied
What kind of a script? What does it do? Where is it located?
Copy link to clipboard
Copied
It adds the document name on one side and page number on other side (same page) to every page.I have it in C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Javascripts when I had Acrobat 9.In 11 I put it in C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\JavascriptsJane
On Tuesday, August 21, 2018, 11:38:45 a.m. EDT, try67 <forums_noreply@adobe.com> wrote:
Using a javascript with Adobe Acrobat 11 Pro created by try67 in JavaScript - View the full discussion What kind of a script? What does it do? Where is it located?
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10572486#10572486 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10572486#10572486
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
Does the script add a menu entry to Acrobat?
Copy link to clipboard
Copied
It did in 9. Can`t get it working in 11.Would it help if I sent you the scriptJane
On Tuesday, August 21, 2018, 12:07:47 p.m. EDT, Bernd Alheit <forums_noreply@adobe.com> wrote:
Using a javascript with Adobe Acrobat 11 Pro created by Bernd Alheit in JavaScript - View the full discussion Does the script add a menu entry to Acrobat?
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10572587#10572587 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10572587#10572587
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
You've put it in the right location. Did you make sure to restart Acrobat after installing it there, though?
If so, are there any error messages in the JS Console (Ctrl+J) when you start the application?
Where did the script add the menu item in the previous version of Acrobat?
Copy link to clipboard
Copied
Yes, I restarted Acrobat.
Yes an error pops up in the console:Acrobat EScript Built-in Functions Version 11.0
Acrobat SOAP 11.0
SyntaxError: illegal character
1:Folder-Level:App:AnnoDocFile.js
In Version 9 - I am not sure but I think it was under Edit
I can`t go back and look because 9 is no longer working.
Nothing shows up in the menu for version 11.
Jane
On Tuesday, August 21, 2018, 1:12:49 p.m. EDT, try67 <forums_noreply@adobe.com> wrote:
Using a javascript with Adobe Acrobat 11 Pro created by try67 in JavaScript - View the full discussion You've put it in the right location. Did you make sure to restart Acrobat after installing it there, though? If so, are there any error messages in the JS Console (Ctrl+J) when you start the application? Where did the script add the menu item in the previous version of Acrobat?
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10572699#10572699 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10572699#10572699
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
There's an error in your .js file, then. Did you edit it using Word, or something like that?
Copy link to clipboard
Copied
I edited it using Notepad.Here is my javascript: {
}
app.addMenuItem(
{
cName:"Annotate Doc File",
cParent:"Document",
cExec:"ann_doc_file();",
cEnable:"event.rc = (event.target != null);",
nPos:0
}
);
app.addMenuItem(
{
cName:"-",
cParent:"Document",
cExec:"",
nPos:1
}
);
function doc_file_def(f)
{
f.textFont = "Helvetica-Bold";
f.textSize = 18;
f.alignment = "left";
f.textColor = color.black;
f.fillColor = color.white;
//f.fillColor = color.transparent;
}
function check_valid_filename(filename)
{
var rea = /^D[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/;
var reb = /^D[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/;
var rec = /^D[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/;
if(rea.test(filename) || reb.test(filename) || rec.test(filename))
{
return true;
}
else
{
app.alert(
util.printf(
"The current filename, \"%s\", appears to be inappropriate.\n\n",filename
)+
util.printf(
"Please rename this file to the appropriate \"Data Document Number\" before continuing.\n"
)
);
return false;
}
}
function check_security_setting(handle,filename)
{
if(handle == null)
{
return true;
}
else
{
app.alert(
util.printf(
"Document \"%s\" is a secure document which does not allow changes.\n\n",filename
)+
util.printf(
"Please print, then scan this document before running \"Annotate Doc File\".\n\n"
)+
util.printf(
"For additional information, please choose:\n\n"
)+
util.printf(
" \"File > Document Properties > Security\"\n\n"
)+
util.printf(
"to view or change the current Document Security Properties.\n"
)
);
return false;
}
}
function ann_doc_file()
{
var docfile = "C:\Program Files (x86)\Adobe\Acrobat 11.0\DocFileSh1.pdf";
// Replace Document Title with File Name
var filename = this.path.replace(/.*\/|\.pdf$/ig,"");
if(check_security_setting(this.securityHandler,filename) && check_valid_filename(filename))
{
this.info.Title = filename;
// Insert Sheet 1
if(this.getField("DocNo") == undefined)
{
try{this.insertPages(-1,docfile);}
catch(e){app.alert(util.printf("\"%s\" File Not Found\n",docfile));}
}
if(this.getField("DocNo") != undefined)
{
// Update Document Number
var f = this.getField("DocNo");
f.value = util.printf("DOCUMENT NO. %s",this.info.Title);
}
if(this.getField("RefDwgNo") != undefined)
{
// Update Reference Drawing Number
var refno = filename.substr(1,3);
var f = this.getField("RefDwgNo");
f.value = util.printf("\(REF DWG NO. %s-XXX\)",refno);
}
if(this.getField("SheetNo") != undefined)
{
// Update Number of Sheets
var f = this.getField("SheetNo");
f.value = util.printf("SH 1 OF %d",this.numPages);
}
for(var i = 0; i < this.numPages; i++)
{
// Not Sheet 1
if(i > 0)
{
var size = this.getPageBox("Crop",i);
// Add Document Number
var r = [size[0]18, size[1]-18-26, size[0]18+105, size[1]-18];
var f = this.addField(util.printf("DocNo%0004d", i+1),"text",i,r);
doc_file_def(f);
f.value = this.info.Title;
// Add Sheet Number
var r = [size[2]-18-80, size[1]-18-26, size[2]-18, size[1]-18];
var f = this.addField(util.printf("p%0004d", i+1),"text",i,r);
doc_file_def(f);
f.alignment = "right";
f.value = util.printf("SH %d", i+1,this.numPages);
}
}
}
}
On Tuesday, August 21, 2018, 1:22:43 p.m. EDT, try67 <forums_noreply@adobe.com> wrote:
Using a javascript with Adobe Acrobat 11 Pro created by try67 in JavaScript - View the full discussion There's an error in your .js file, then. Did you edit it using Word, or something like that?
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10572784#10572784 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10572784#10572784
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
Why did you add the pair of curly brackets at the start of your code? You should remove them.
Also, you might have noticed that there isn't a Document menu in Acrobat XI, so you can't add a menu item to it...
Change it to Edit, for example, or use addToolButton instead, and the button will be added under Tools - Add-On Tools.
Copy link to clipboard
Copied
I tried both suggestions - changing to "Edit" instead of "Document" and "addToolButton" instead of "addMenuItem".Neither worked.Any other idea I could try?
On Tuesday, August 21, 2018, 3:05:47 p.m. EDT, try67 <forums_noreply@adobe.com> wrote:
Using a javascript with Adobe Acrobat 11 Pro created by try67 in JavaScript - View the full discussion Why did you add the pair of curly brackets at the start of your code? You should remove them. Also, you might have noticed that there isn't a Document menu in Acrobat XI, so you can't add a menu item to it... Change it to Edit, for example, or use addToolButton instead, and the button will be added under Tools - Add-On Tools.
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10572989#10572989 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10572989#10572989
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
You'll need to share the actual script file with us for further help.
Also, when replying via email please turn off the function to include previous emails in the reply. It's creating very long replies which are annoying to go over.
Copy link to clipboard
Copied
Here is the changed script:
app.addToolButton( {
cName:"Annotate Doc File",
cParent:"Edit",
cExec:"ann_doc_file();",
cEnable:"event.rc = (event.target != null);",
nPos:0
}
);
app.addToolButton(
{
cName:"-",
cParent:"Edit",
cExec:"",
nPos:1
}
);
function doc_file_def(f)
{
f.textFont = "Helvetica-Bold";
f.textSize = 18;
f.alignment = "left";
f.textColor = color.black;
f.fillColor = color.white;
//f.fillColor = color.transparent;
}
function check_valid_filename(filename)
{
var rea = /^D[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/;
var reb = /^D[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/;
var rec = /^D[0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]$/;
if(rea.test(filename) || reb.test(filename) || rec.test(filename))
{
return true;
}
else
{
app.alert(
util.printf(
"The current filename, \"%s\", appears to be inappropriate.\n\n",filename
)+
util.printf(
"Please rename this file to the appropriate \"Data Document Number\" before continuing.\n"
)
);
return false;
}
}
function check_security_setting(handle,filename)
{
if(handle == null)
{
return true;
}
else
{
app.alert(
util.printf(
"Document \"%s\" is a secure document which does not allow changes.\n\n",filename
)+
util.printf(
"Please print, then scan this document before running \"Annotate Doc File\".\n\n"
)+
util.printf(
"For additional information, please choose:\n\n"
)+
util.printf(
" \"File > Document Properties > Security\"\n\n"
)+
util.printf(
"to view or change the current Document Security Properties.\n"
)
);
return false;
}
}
function ann_doc_file()
{
var docfile = "C:\Program Files (x86)\Adobe\Acrobat 11.0\DocFileSh1.pdf";
// Replace Document Title with File Name
var filename = this.path.replace(/.*\/|\.pdf$/ig,"");
if(check_security_setting(this.securityHandler,filename) && check_valid_filename(filename))
{
this.info.Title = filename;
// Insert Sheet 1
if(this.getField("DocNo") == undefined)
{
try{this.insertPages(-1,docfile);}
catch(e){app.alert(util.printf("\"%s\" File Not Found\n",docfile));}
}
if(this.getField("DocNo") != undefined)
{
// Update Document Number
var f = this.getField("DocNo");
f.value = util.printf("DOCUMENT NO. %s",this.info.Title);
}
if(this.getField("RefDwgNo") != undefined)
{
// Update Reference Drawing Number
var refno = filename.substr(1,3);
var f = this.getField("RefDwgNo");
f.value = util.printf("\(REF DWG NO. %s-XXX\)",refno);
}
if(this.getField("SheetNo") != undefined)
{
// Update Number of Sheets
var f = this.getField("SheetNo");
f.value = util.printf("SH 1 OF %d",this.numPages);
}
for(var i = 0; i < this.numPages; i++)
{
// Not Sheet 1
if(i > 0)
{
var size = this.getPageBox("Crop",i);
// Add Document Number
var r = [size[0]18, size[1]-18-26, size[0]18+105, size[1]-18];
var f = this.addField(util.printf("DocNo%0004d", i+1),"text",i,r);
doc_file_def(f);
f.value = this.info.Title;
// Add Sheet Number
var r = [size[2]-18-80, size[1]-18-26, size[2]-18, size[1]-18];
var f = this.addField(util.printf("p%0004d", i+1),"text",i,r);
doc_file_def(f);
f.alignment = "right";
f.value = util.printf("SH %d", i+1,this.numPages);
}
}
}
}
On Wednesday, August 22, 2018, 9:47:47 a.m. EDT, try67 <forums_noreply@adobe.com> wrote:
Using a javascript with Adobe Acrobat 11 Pro created by try67 in JavaScript - View the full discussion You'll need to share the actual script file with us for further help.
Also, when replying via email please turn off the function to include previous emails in the reply. It's creating very long replies which are annoying to go over.
If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/10574561#10574561 and clicking ‘Correct’ below the answer
Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/10574561#10574561
To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
Start a new discussion in JavaScript by email or at Adobe Community
For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.
This email was sent by Adobe Community because you are a registered user. You may unsubscribe instantly from Adobe Community, or adjust email frequency in your email preferences |
Copy link to clipboard
Copied
Your use of addToolButton is wrong. And you can't get an error message?
Copy link to clipboard
Copied
Any error message in the console?
Copy link to clipboard
Copied
No error message in the console.
Copy link to clipboard
Copied
The following works for me:
app.addMenuItem(
{
cName:"Annotate Doc File",
cParent:"Edit",
cExec:"ann_doc_file();",
cEnable:"event.rc = (event.target != null);",
nPos:0
}
);
Did you restart Adobe Acrobat?
Copy link to clipboard
Copied
I restarted Adobe Acrobat.Got the following error in the console that popped up:Acrobat EScript Built-in Functions Version 11.0
Acrobat SOAP 11.0
SyntaxError: illegal character
1:Folder-Level:App:AnnoDocFile.js
Copy link to clipboard
Copied
Remove the illegal character.
Copy link to clipboard
Copied
Where is the illegal character?
Copy link to clipboard
Copied
Look at the error message. It is at line 1.
Copy link to clipboard
Copied
Here is the start of my script. What in line 1 is the illegal character?
app.addMenuItem
{
cName:"Annotate Doc File",
cParent:"Edit",
cExec:"AnnoDocFile.js;",
cEnable:"event.rc = (event.target != null);",
nPos:0
}
);
Copy link to clipboard
Copied
It can be a non-visible character. Delete the first lines and re-enter the code.
Info: the parameter cExec is incorrect.
Copy link to clipboard
Copied
I tried deleting the existing lines and re-entering them.Still getting this error (see below). I am really stumped.
Acrobat EScript Built-in Functions Version 11.0
Acrobat SOAP 11.0
SyntaxError: illegal character
1:Folder-Level:App:AnnoDocFile.js
Copy link to clipboard
Copied
Can you share the file?