Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thank you so much for your help. I will check out your custom-made scripts ASAP.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
You have to select all the code before the last step. Did you do that?
Copy link to clipboard
Copied
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:/
Copy link to clipboard
Copied
The code itself looks fine and the "None" at the end is not an indication of a problem.
What do you mean by "highlighted", exactly?
Copy link to clipboard
Copied
Hi,
first thank you for your support I really appreciate it.
I try to explain my complete case
I convert a PDF from a PowerPoint File which I had created. In this Power Point File I created Buttons(Boxes with Links) for a menue which is clickable at the right side of the document. The buttons keep transparent while clicking. After the conversion to the Acrobat PDF all those buttons got the highlight state set to "invert" which turns the background of the button/links to black (see picture attached).
You can change the highlight style by right click -> edit link -> and then set the highlight state to none. But with 100 pages and 11 buttons each page it would be quite a pain and effort to do that for all the buttons in the document. That's why I am searching for a solution how I can set all highlight states to "none" with Javascript.
Copy link to clipboard
Copied
Are you saying you run the code but the links still behave the same as before? Did the Highlight Style setting change?
Can you share the file in question?
I've tried your code on a link object I created with the Invert highlighting mode, converting it to None, and it worked fine.
Copy link to clipboard
Copied
Hi,
exactlly.. How can I send you a file? I have created an example because the original file is confidential. But there I have the same issues.
I can only attach pictures and video in this forum.
Copy link to clipboard
Copied
The forum does not allow attachment of generic files for obvious security reasons.
To share a document with another user, upload it to a file-sharing service (Creative Cloud, Dropbox, Google Drive, etc.) and send the link via a Private Message. We do not suggest posting the link as part of the public thread.
Copy link to clipboard
Copied
I got the file via private message. This is a nice example of how things can go both wrong and right at the same time, which can be the most difficult problem to solve, as there are no error messages. It simply doesn't work. So the question is, why not?
If you'll notice, the way the getLinks method works is based on a page number and a "box". Normally, we define this box to be the same as the page size, and assume that will retrieve all the links on the page. However, if a link is not entirely enclosed within that box then it won't be included in the array this method returns. I believe that's what is happening in your case, since the right edge of the link boxes overlaps the crop box of the file, or slightly goes beyond it. If you move those links a tiny bit to the left (or change the values of the box rectangle array) you'll see that it works.
Copy link to clipboard
Copied
Thank you much.. you made my day It works now
Copy link to clipboard
Copied
Hi there,
This is great thanks, and I don't know if you are still in this thread - but I can't seem to run the code properly. I input it into the console, run it and I get 'None'. Following your comments, I have ensured all links are within the cropbox but it still will not run.
Any ideas as to why? Thanks
Copy link to clipboard
Copied
It is also worth mentioning that I was able to run the code to identify all the links within my document (there are ~400), but the code you provided won't run. I am sure it is something I am doing wrong as I am not exactly fluent by any means with JavaScript.

