Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Feb 19, 2016 Feb 19, 2016

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

TOPICS
Acrobat SDK and JavaScript
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 19, 2016 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 19, 2016 Feb 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2016 Feb 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);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 19, 2016 Feb 19, 2016

I pasted this into the JavaScript console and this was the error message I got:

ReferenceError: p is not defined

1:Console:Exec

undefined

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2016 Feb 19, 2016

Make sure you select all of the code with the mouse (or keyboard) before running it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 19, 2016 Feb 19, 2016

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2016 Feb 20, 2016
LATEST

In Acrobat Pro you can create an action for this. Look at the Action Wizard.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 19, 2016 Feb 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines