Change the text color of all links using JavaScript
Copy link to clipboard
Copied
Is there a way using JavaScript to change the text color of every link to blue?
Copy link to clipboard
Copied
Links don't have text (or text color) in PDF files. They are simply transparent boxes that exist above the text, so no, you can't do that. The only thing you can change about them is their border style (none, underline, dashed, etc.), width and color.
Copy link to clipboard
Copied
Thanks,
That's what I was afraid of.
So, I'm trying to use the script below and underline every link in blue but I can't get the LineStyle syntax correct.
What is the correct syntax for that?
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;
for (var i in links) {
links[i].borderColor = color.blue;
links[i].borderWidth = 1;
links[i].LineStyle = "Underline";
}
}
Copy link to clipboard
Copied
Sorry, that's actually not editable using a script, unfortunately. I was thinking of button fields, not links.
Copy link to clipboard
Copied
If you can, I recommend converting your links to buttons. They work pretty much exactly the same, but buttons are much more customizable, including setting their text ("caption"), text color, border style, etc.

