These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

JavaScript in Document Actions

djjones
Registered: Jul 24 2007
Posts: 14

I'm trying to run a javascript in WillPrint Document Actions. A for loop is setup to count the text fields on the document, validate the value is not null and then change the border color when condition is true to transparent but nothing is working. The Debugger is setup and I get through errors but It's like something is is not turned on. Can you please help. I can send the script if need be.
 
Thanks
Deedee

My Product Information:
Acrobat Pro 7.0.8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
If your script is throwing exceptions then obviously it's not going to work. It probably has nothing to do with the WillPrint event. So yes, please post your code.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

djjones
Registered: Jul 24 2007
Posts: 14
Thanks Thom for your respones. As it turns out, I wasn't event getting in the the for loop in order to validate the text field boxes. It's working now. The script is posted below. Now I'm trying to put the boxes back via the "Clear" button and reset the fields once the form is printed. I thought I could simply use the same code and make the strokeColor my custom RGB, 255,191,170, but when I click the "Clear" button, it's removing more text boxes instead of adding them back to the form. You might be able to tell I'm a newbie at JavaScript, but I'm catching on a little.

WILLPRINT DOCUMENT ACTION script:
for ( var i = 0; i < this.numFields; i++)
{
var fname = this.getNthFieldName(i);

var f = this.getField(fname);
if (!(f.valueAsString == ''))
{
color.transparent = new Array("T")
f.strokeColor = color.transparent
};
};CLEAR button script
for ( var i = 0; i < this.numFields; i++)
{
var fname = this.getNthFieldName(i);

var f = this.getField(fname);
if (f.valueAsString == " ")
{
colLtPink = new Array("RGB", 255,191,170)
f.strokeColor = colLtPink
};
};