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

this.getField("field1").display = display.hidden dosent make field invisible?

adoacr
Registered: May 4 2011
Posts: 41

Hi,
 
Im trying to make a text field invisible to the viewer and print but invoking
this.getField("field1").display = display.hidden
dosent seem to do the trick...
The field just becomes inactive and the user cant click in the text field but it is still visible... this is an acroform field.any idead why this might be and wether I should use some other syntax?

try67
Expert
Registered: Oct 30 2008
Posts: 2398
Are you getting any error messages in the console?

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

adoacr
Registered: May 4 2011
Posts: 41
I dont see any error messages ...
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Do you have the option to show the console on errors and warnings ticked on in the preferences?
In addition, does it work when you execute just that line from the console?

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

adoacr
Registered: May 4 2011
Posts: 41
just did that, restarted reader and tried. same effect. no error or warning comes up with the console. could it be that I should do a doc.getField("field1").display = display.hidden instead of 'this'?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
No, using "this" is fine... This is odd.
If you want, send me the file by email and I'll have a look.
Also, in which exact version of Reader/Acrobat are you running this?

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

adoacr
Registered: May 4 2011
Posts: 41
here is the javscript. I added this line in a function that sets the watermark layer to false.

function SetOCGState(doc, bState) {
/* set the "Watermark" to bState for doc
doc - doc object to process
bState - value for logical state
true = show
false = hide
*/

var ocgArray = doc.getOCGs();
for (var i=0; i < ocgArray.length; i++) {
if (ocgArray[i].name == "OCG1") {
ocgArray[i].state = bState;
} // end if Watermark
} // end loop through the OCG object
doc.getField("sField1").display = display.hidden;
return;
} // end SetWatermarkState function
right now the text field just kinda turns 'read-only' and whatever was in the field gets blanked out.
try67
Expert
Registered: Oct 30 2008
Posts: 2398
The code looks fine. My guess is that you have multiple copies of the same field one on top of another, but I can't say for sure unless I see the actual file.

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

adoacr
Registered: May 4 2011
Posts: 41
im thinking this may b because the form fields were added on in the form of acroform. isnt javascript for acroform objects a bit differen?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
Compared to what?

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

adoacr
Registered: May 4 2011
Posts: 41
one possibility is setting the text field bordercolor and label fontcolor to white, would have the same effect, since the field is being rendered readonly already... what are the field methods for this and where can I find a refrence for the acrobat javascript field properties ...?
try67
Expert
Registered: Oct 30 2008
Posts: 2398
http://www.adobe.com/devnet/acrobat/javascript.php

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

adoacr
Registered: May 4 2011
Posts: 41
hmm.even that dosent seem to work. How about just putting a redaction (Opaque BBox) over those
fields? Opening the PDF in notepad shows me the field looks like the below. How would I go about
getting the coordinates for the BBox:

<>
endobj
199 0 obj
<>
endobj
189 0 obj
<>/F 4/T(sField1)/V/Rect[293.5 512.2 437 529.3]/Subtype/Widget/DR<>/DV/DA(0 0 0 rg /F2 12 Tf)/FT/Tx>>
endobj
200 0 obj
<>stream