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

what script would I use to clear specific fields using the "Did print" action?

kaffka
Registered: Mar 9 2011
Posts: 2
Answered

Hi,
This is probably a very simple script but I am clueless about JS. I have programed (or I should say copy and pasted other programmers code) into a PDF document and some PDF forms to only print under the "will print" action; however, I need the fields to auto clear after the printing is done.
I have read allusions to the fact it can be done but I can't find the code anywhere, help!

My Product Information:
Acrobat Pro 9.4, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Use something like this (adjust the field names to match those in your file, of course):

this.getField("field1").value = "";
this.getField("field2").value = "";
this.getField("field3").value = "";

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
To reset the entire form, do this:

resetForm();


and you'll want to use the "Did Print" event for this.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Accepted Answer
If you want to clear only certain form fields, then you need to provide the optional parameter of an array of the field names to clear.

// array of field names to clear
var aFields = new Array("field1", "field2", "field3');
// clear the field in the array of names
this.resetForm(aFields);

As noted, omitting the array of field names, clears all of the form fields.

George Kaiser

kaffka
Registered: Mar 9 2011
Posts: 2
Thank you very much. I think deciphering what people like me want is half the battle to answering questions.
Cheers