Skip to main content
pikablu505
Participant
February 19, 2016
Question

What's the script for getting a hyperlink count for PDF documents?

  • February 19, 2016
  • 2 replies
  • 2278 views

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

This topic has been closed for replies.

2 replies

Inspiring
February 19, 2016

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.

Inspiring
February 19, 2016

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.

pikablu505
Participant
February 19, 2016

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?

try67
Community Expert
Community Expert
February 19, 2016

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);