How to make Highlight Existing Fields a default setting using Javascript

When my boss opened a form I created, the fields were not highlighted, so he was unaware he had the option to enter data into six fields. In addition, each field includes a tooltip, but those did not appear when he had the "Highlight Existing Fields" off. I would like a default setting to highlight existing fields so that fields and tooltips are visible when users open the form. The highlight color doesn't need to be specific; I just want the fields highlighted.

I tried the following code in a field's Custom Format. It highlighted all the fields, but it also changed the user's preferences:

if (!app.runtimeHighlight)
{
app.runtimeHighlight = true;
//to change color:
app.runtimeHighlightColor = ["RGB",0.85,0.91,1];
}

How do I save the user's value and reset it upon closing the PDF?

I also tried this document level script, but it isn't working or I don’t know how to make it work. Do I need to add additional script in the fields to make it work?

function Init() {
if (!app.runtimeHighlight) {
// if highlight not on turn on
app.runtimeHighlight = true;
}
if (!app.runtimeHighlight && !app.runtimeHighlightColor ) {
// if no color set color to light blue.
app.runtimeHighlightColor = ["RGB",0.85,0.91,99];
}
return;
}

I am working with Acrobat XI and the users are working with Acrobat Reader 10 and XI.

Your expert help is needed – thank you!


Melanie Garcia


Voted Best Answer

When opening the document (in a document-level script), you save the current setting of app.runtimeHighlight, and set it to true, such as in

var arh = app.runtimeHighlight ;
app.runtimeHighlight = true ;

When closing the document (in the willClose event), you set app.runtimeHighlight to the value you have saved when the document has been opened, such as in

app.runtimeHighlight = arh ;

Hope this can help.

Max Wyss.


By Max Wyss   


Please specify a reason: