View total number of links within a pdf document
Copy link to clipboard
Copied
I'm creating a pdf that has links throughout the document. Is there a way to view the total number of links contained within the pdf document once complete? I estimate there will be over 1000 and I'd rather not try to count those manually.
Thanks!
Copy link to clipboard
Copied
Assuming they are actual Link objects you can use this script to count them all up:
var total = 0;
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;
total+=links.length;
}
app.alert("There are " + total + " links in this file.",3);
Copy link to clipboard
Copied
Hi, I am also a novice at this - how would I apply this script? Do I have to have Acrobat or can I do this count through Adobe Reader? Thank you!
Copy link to clipboard
Copied
It's possible to use that code in Reader but it's quite tricky since you can't access the JS Console that easily.
What you can do is put the code in a .js file in the application's JavaScripts folder and then attach it to a toolbar button that will execute it when clicked.
Copy link to clipboard
Copied
Hi, after adding the script where can I see the number of click?
Copy link to clipboard
Copied
It will appear in an alert window when you run it, like this:
Copy link to clipboard
Copied
Hi,
here is a script you can use for counting the number of links in your document:
var nbLinks=0;
for (var p=0; p < this.numPages; p++) {
var zone=this.getPageBox("Crop", p);
var theLinks=this.getLinks(p, zone);
nbLinks+=theLinks.length;
}
console.println("Number of links in this document: " + nbLinks);
@+
Copy link to clipboard
Copied
oups! too late...

