Copy link to clipboard
Copied
Courtesy of member @try67, I now have this JavaScript running in the JavaScript (JS) Interactive Console:
[See: https://community.adobe.com/t5/acrobat-discussions/identifying-all-hidden-hyperlinks-in-a-pdf-using-... ]
However, as I've this is my first time using the JS Console, I don't know how to convert this to a permanent macro. Ideally I'd like to be able to add it as a button to my Ribbon. But barring that, I'd like to save it wherever these scripts are stored, so that I can call it up as needed. Please note that I don't want it to be tied to any specific document. Rather, I'd like it to be runnable in any PDF.
Can anyone either explain how to do this, or provide an instructional link?
I looked through Adobe's JavaScript materials, and wasn't able to find specific instructions.
Copy link to clipboard
Copied
If you want it to be placed in a 'ribbon' you can add custom tool.
Save js file with this script:
var rLinks = app.trustedFunction(function()
{
app.beginPriv();
for (var p=0; p<this.numPages; p++) {
var box = this.getPageBox("Crop", p);
var links = this.getLinks(p, box);
if (links==null || links.length==0) continue;
for (var i in links) {
links[i].borderWidth = 1;
links[i].borderColor = color.blue;
}
}
app.endPriv();
});
app.addToolButton({
cName: "Remove links",
cLabel: "Remove links",
cExec: "rLinks()",
cTooltext: "",
nPos: 0});
Then place file in JavaScript folder.
Now open acrobat and go to tools, you should see this:
Select it and now you should have new tool in your ribbon:
Copy link to clipboard
Copied
You can create an action in the Action Wizard for this.
Copy link to clipboard
Copied
The documentation I found is limited. This talks about creating custom commands using the Action Wizard, but not much specifically about JavaScripts: https://helpx.adobe.com/acrobat/using/action-wizard-acrobat-pro.html
Nevertheless, after stumbling about, I think I managed to create a new action using a Javascript:
And now it actually seems to be there, as evidenced by this:
Is there anywhere that the sequence of steps I just took is actually documented? And, more importantly, how do I actually run this Action, and/or add it as a button to my ribbon or menu? I can't figure out that step, and I can't find any documentation that says "Once you've saved your JavaScript as an Action, to run it you....."
Copy link to clipboard
Copied
Look at the help for instructions to run the action.
Copy link to clipboard
Copied
Thanks Bernd, that worked. As an alternative to adding the Action to the Ribbon, does Acrobat have a way to assign shortcuts to Actions? If not, I can probably create on using KeyBoard Maestro.
Copy link to clipboard
Copied
You can also add a custom menu item, read this:
Copy link to clipboard
Copied
I looked through those instructions. I ran this code...
app.getPath("app","javascript");
.... and got the path where my Javascript folder is stored.
And I understand I'm supposed to create a text file, Config.js, and add this to it:
app.addMenuItem({cName:"-", cParent:"Help", cExec:" "}); app.addMenuItem({cName:"JS Ref", cParent:"Help", cExec:"app.openDoc('/C/Acrobat Docs/YourFile.pdf');"
....where I substitute the desired name of the menu item for "JS Ref", and substitute my own path for the path shown above.
However, I'm stumped by this...
"app.openDoc('/C/Acrobat Docs/YourFile.pdf');"
The documentation says:
"This code assumes the JavaScript Reference is stored on the C drive in the Acrobat Docs subfolder. You will need to modify this path to the specific location on your system where this file exists."
What does Thom mean by "Java Script Reference"? And doesn't this code need to refer back to my JavaScript file (which it seems I'd still need to create and store as a .js text file), rather than to a PDF?
Copy link to clipboard
Copied
The JavaScript Reference is part of the Acrobat SDK.
Copy link to clipboard
Copied
If you want it to be placed in a 'ribbon' you can add custom tool.
Save js file with this script:
var rLinks = app.trustedFunction(function()
{
app.beginPriv();
for (var p=0; p<this.numPages; p++) {
var box = this.getPageBox("Crop", p);
var links = this.getLinks(p, box);
if (links==null || links.length==0) continue;
for (var i in links) {
links[i].borderWidth = 1;
links[i].borderColor = color.blue;
}
}
app.endPriv();
});
app.addToolButton({
cName: "Remove links",
cLabel: "Remove links",
cExec: "rLinks()",
cTooltext: "",
nPos: 0});
Then place file in JavaScript folder.
Now open acrobat and go to tools, you should see this:
Select it and now you should have new tool in your ribbon:
Copy link to clipboard
Copied
Thanks Nesa. I saved it as plain text file under the name Show_Hyperlinks.js in:
/Macintosh HD/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Resources/JavaScripts/
However, when I went to tools, I did not see an Add-on icon anywhere. There's still nothing below the Customize row:
Copy link to clipboard
Copied
Ah, never mind. There's an extra step required: You need to quit Acrobat. When you reopen it, the icon appears. [I didn't think anything was needed when you wrote "open Acrobat", since mine was already opened. But I now understand you were assuming it was closed.]
That expanded script you wrote is pretty nifty! And it will make it easier to distribute to my colleagues, since now they just need to save a file.
I was hoping it might actually be possible to add it permanently to the regular (top) ribbon, here....
..but this should be good enough.
Do you know if Acrobat allows one to create custom shortcuts for these? If not, I can probably create one with KeyBoard Maestro.
Copy link to clipboard
Copied
No, you can't add keyboard shortcuts to toolbar items, only to menu items.

