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

View total number of links within a pdf document

New Here ,
Jan 16, 2020 Jan 16, 2020

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!

TOPICS
Create PDFs , Edit and convert PDFs , General troubleshooting , How to , PDF forms
3.7K
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 ,
Jan 16, 2020 Jan 16, 2020

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);
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 ,
May 14, 2020 May 14, 2020

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!

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 ,
May 14, 2020 May 14, 2020

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.

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 ,
Nov 26, 2021 Nov 26, 2021

Hi, after adding the script where can I see the number of click?

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 ,
Nov 26, 2021 Nov 26, 2021
LATEST

It will appear in an alert window when you run it, like this:

 

try67_0-1637966360181.pngexpand image

 

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 ,
Jan 16, 2020 Jan 16, 2020

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

@+

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 ,
Jan 16, 2020 Jan 16, 2020

oups! too late...

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