These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Extract all link image in a document

finfed
Registered: May 16 2010
Posts: 6

I need to extratc all link image in a document and report a list of href.
My code only count the number of links on page but don't work completely.
May yuo help me?
Thanks!

var rep = new Report();
rep.size = 1.2;
rep.color = color.blue;
rep.writeText ("Testing for Content");
rep.writeText("FileName : " + this.documentFileName);
for (var i = 0; i < this.numPages; i++ ) // loop thru all pages
{
var a= this.getAnnots();
var c = this.getOCGs();
var b = this.getPageBox("Crop", i);
var aLinks = this.getLinks(i, b);
rep.indent(20);
for (l = 0; l < aLinks.length; l += 1)
{
rep.writeText((l+1) + " " + aLinks[l].name);
}

rep.writeText("Number of Links on page " + (i+1) +" is " + aLinks.length);
if (a != null ) rep.writeText("There are annotations on page " + (i+1));
if (c != null ) rep.writeText("There are layers in this document.")

}
var docRep = rep.open("myreport.pdf");

My Product Information:
Acrobat Pro 9.0, Windows
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Link objects don't have a name property.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

finfed
Registered: May 16 2010
Posts: 6
Ok!
Is there an alternative way to get the link name ?
Do you know it?
May you explain with a quick example? thanks.
try67
Online
Expert
Registered: Oct 30 2008
Posts: 2399
Links don't have names. Do you mean the link's address? I'm afraid that's not possible either.
The only properties available in JavaScript for this object are: borderColor, borderWidth, highlightMode and rect.

If you want a list of the addresses to which the links in a PDF point to, you will need to use a plugin or an external application.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Acrobat JavaScript does not have access to all the details of links. You can see what the Acrobat JS link object has access to in the Acrobat JS API Reference. I do not see any 'name' property in Acrobat JavaScirpt, or in the properties of a link provided by the Acrobat Link Tool .

You will need to find a 3rd party plug in to obtain more information about links.

George Kaiser

finfed
Registered: May 16 2010
Posts: 6
Ok!
All thanks.