Copy link to clipboard
Copied
There is a tool for "documents will print", I would like to clear all default place holders. is this possible?
I found and modified this script and I added in an alert and the default values are not deleted,
for ( var i = 0; i < this.numFields; i++) {
var fname = this.getNthFieldName(i);
var ffield = this.getField(fname);
console.println("fname: "+ fname + " - ffield.value: " + ffield.value);
if (ffield != null && ffield.value==ffield.defaultValue) {
ffield.value = "";
}
}
Copy link to clipboard
Copied
The code seems fine. Where exactly did you place it, and what is the result of running it?
Also, are there error message in the JS Console?
Copy link to clipboard
Copied
the code is placed in the Document Actions under "Document Will Print" as I want the defaults to be cleared before it prints
Copy link to clipboard
Copied
The error I get is "InvalidSetError: Set not possible, invalid or unknown"
Copy link to clipboard
Copied
You should exclude buttons and signature fields from your loop.
Copy link to clipboard
Copied
this makes sense. Dropdowns and checkboxes too?
Copy link to clipboard
Copied
That's up to you, but you must exclude buttons and signatures because they have no default value.
Copy link to clipboard
Copied
You are a master thanks very much for your sugestion.
Copy link to clipboard
Copied
A portion of the problem is that there are periods and spaces in the field names. IS there a quick javascript that I can run to remove these? There seems to be a replace function, except it doesn't seem to work with changing the names. I found a setAttribute in regular javascript except there doesn't seem to be one in acrobat javascript.
Copy link to clipboard
Copied
Interestingly enough I got a Adobe Acrobat popup saying "Do you really want to execute the script: App:Init? Executing it could interfere with teh debugging session currently under way."
Copy link to clipboard
Copied
Is it possible that my onfocus behavior is conflicting with this process?