Copy link to clipboard
Copied
I have a need on a daily basis to be able to get a link count from PDF documents that are usually over 150 pages long. What's the script that I can put into the Java console to get the answer to the number of links?
Also, is there a way to make that a macro or a menu item?
Thank you
Copy link to clipboard
Copied
You can use the doc.getLinks method to retrieve an array of Link objects within a region of a page. The Acrobat JavaScript documentation for this method has some sample code that should get you started, but post again if you get stuck.
Copy link to clipboard
Copied
Any chance you can dumb this down for me? I got as far as opening the JavaScript console in Acrobat ready to copy and paste a command into it.
Your response doesn't fit where I'm at. Any chance you could elaborate?
Copy link to clipboard
Copied
This is the code George was referring to from the API:
var numLinks=0;
for ( var p = 0; p < this.numPages; p++)
{
var b = this.getPageBox("Crop", p);
var l = this.getLinks(p, b);
console.println("Number of Links on page " + p +" is " + l.length);
numLinks += l.length;
}
console.println("Number of Links in Document is " + numLinks);
Copy link to clipboard
Copied
I pasted this into the JavaScript console and this was the error message I got:
ReferenceError: p is not defined
1:Console:Exec
undefined
Copy link to clipboard
Copied
Make sure you select all of the code with the mouse (or keyboard) before running it.
Copy link to clipboard
Copied
THANK YOU SO MUCH!
Now... One more thing. Can I make it a menu item so I don't have to run that every time?
Thank you soooo much!
Copy link to clipboard
Copied
In Acrobat Pro you can create an action for this. Look at the Action Wizard.
Copy link to clipboard
Copied
Also, it can be made into a menu item, custom toolbar, and an Acrobat DC custom command: Create Custom Commands in Adobe Acrobat DC Pro - KHKonsulting LLC
If you have a preference among these options, there are tutorials available, so post again if you need help finding them.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now