Skip to main content
Participant
October 28, 2025
Question

Hide Highlights and Document Will Close Java Script in PDF not working as intended

  • October 28, 2025
  • 2 replies
  • 170 views

Hello all! 

Java Script beginner here, not even really a begginer, I only ever used the one script below that I'm now having troubles with. So let me know if you need more info to be able to help with my question.

I recently created an editable PDF for a client that needed the highlights for editable fields removed. I used the standard Java Script to hide the highlights:

var rths = app.runtimeHighlight ;

app.runtimeHighlight = false ;

Then I also set Document Actions > Document Will Close to this:

app.runtimeHighlight = rths ;
to ensure that specific Java Script only works for that specific file. So, once that document was closed out of the highlights would show properly for all other files. 

This worked for a while but at some point I noticed I stopped seeing highlights in all editable PDFs which shouldn't have happened because of the Document Will Close script. I'm not sure what happened in the process but I always used both scripts noted above as I was making edits to the file after client review.

Is there a Java Script to re-set highlights to visible? Or is there a different way for me to fix this? 

Thank you!

2 replies

JR Boulay
Community Expert
Community Expert
October 28, 2025

runtimeHighlight is a property that is linked to the application, not to a single document.
The best proof of this is that it is a setting found in the software's Preferences.
So when a document activates or deactivates runtimeHighlight , it applies to all open documents.

 

The method you are using is fine when the user opens only one document at a time, but if there are several documents open, the behaviour becomes unpredictable.

There is nothing more you can do to improve this.

 

Acrobate du PDF, InDesigner et Photoshopographe
Participant
October 28, 2025

Thanks for the reply! 

Yes, I'm aware that if you have multiple documents open the script will apply to all of them—This is why I always open one file at a time. However, the issue I'm having is that the highlight isn't showing for other documents I open separetely even though I have the Document WIll Close script applied to the document with the hidden highlight. It worked like a charm when I first started it out but now it doesn't anymore. 

I do want to mention that I've had colleagues open these files on their end and the scripts work as intended. Highlights are hidden in the files with the added JS but they show normally for other files that were unedited. So whatever the issue is seems to only happen on my end and not for other users opening the same files.

Do you think the script mentioned by Bernard above could work? If so, would this simply need to be added via the Document JavaScript option as-is? Or would it need to first include the var rths = app.runtimeHighlight ; part of the original hide highlight script making the full script look like this:

var rths = app.runtimeHighlight ;

app.runtimeHighlight = true ;

 

 

try67
Community Expert
Community Expert
October 28, 2025

The point of saving it to a variable is to restore it back to its original state when the file is closed. Just setting it to "true" should work, but maybe the user didn't have it enabled in the first place...

Bernd Alheit
Community Expert
Community Expert
October 28, 2025

app.runtimeHighlight = true;

Participant
October 28, 2025

Hi Bernd! 

Thanks for the reply! 

Would this script need to be added as-is into the Document JavaScript option or would it need to have the first part of the original hide highlight script var rths = app.runtimeHighlight ;?

So, does the full script need to be: 

var rths = app.runtimeHighlight ;

app.runtimeHighlight = true ;

Or is just the part you mentioned OK to use?

Thanks!