Skip to main content
Participant
July 6, 2017
Answered

Converted interactive PowerPoint to PDF: JavaScript to change highlight state of all buttons from invert to none?

  • July 6, 2017
  • 1 reply
  • 5063 views

Hi, I have created a PDF from a Microsoft Office PowerPoint presentation, which has multiple action buttons and links. Everything works as it should; however, the default highlight style for each button in Acrobat is 'Invert' which turns the background of the invisible button black on rollover/click. I am able to edit each button individually (changing the highlight style to 'None'); however, there are hundreds of buttons. Therefore, I am hoping that there may be some JavaScript that I can use to achieve this task across the document. Normally, I would take the time and try to figure this out for myself before asking for help but circumstances have conspired against me. Therefore, I would really appreciate it if anyone has a solution.

Many thanks,

Julie

This topic has been closed for replies.
Correct answer try67

This code will edit both links and buttons and set their Highlight property to None:

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.highlightMode = "None";

    }

}

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="Button");

        f.highlight = highlight.n;

}

If you're interested in an easy way to edit the properties of multiple fields (not links, though) all at once, check out this tool I've developed:

Custom-made Adobe Scripts: Acrobat -- Mass Edit Fields Properties

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 6, 2017

This code will edit both links and buttons and set their Highlight property to None:

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.highlightMode = "None";

    }

}

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="Button");

        f.highlight = highlight.n;

}

If you're interested in an easy way to edit the properties of multiple fields (not links, though) all at once, check out this tool I've developed:

Custom-made Adobe Scripts: Acrobat -- Mass Edit Fields Properties

fabiankey
Participating Frequently
July 15, 2019

Hello try67,

I have the same issue like juemuse. He didn't respond if it worked at his file. When I use your code in my pdf all my buttons/links keep highlighted.

I am quite a noob in programming and javascript so I wanted to ask if I did everything  correctly:

strg + j,

enter your code in the console:

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.highlightMode = "None"; 

    } 

 

for (var i=0; i<this.numFields; i++)

    var f = this.getField(this.getNthFieldName(i)); 

    if (f==null) continue; 

    if (f.type=="Button"); 

        f.highlight = highlight.n; 

}

then I tapped strg + return

Did I miss something?

kind regards

Fabian

fabiankey
Participating Frequently
July 15, 2019

You have to select all the code before the last step. Did you do that?


No I didn't but I tried it now again with selected text and still nothing happened. The console writes "none" after executing the code :/ But the higlighted Links/buttons are still highlighted:/