Skip to main content
New Participant
March 6, 2023
Question

Change the text color of all links using JavaScript

  • March 6, 2023
  • 1 reply
  • 1230 views

Is there a way using JavaScript to change the text color of every link to blue?

This topic has been closed for replies.

1 reply

try67
Community Expert
March 6, 2023

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.

New Participant
March 6, 2023

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";  
}
}

try67
Community Expert
March 6, 2023

Sorry, that's actually not editable using a script, unfortunately. I was thinking of button fields, not links.