Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm creating an interactive pdf form with the hyperref package. The form is quite comprehensive, so the current goal is to only show parts that are relevant to the specific user. For example, the user indicates that he is male --> only the items that concern males are displayed.

Usually it's not difficult to display only certain parts of a document, e.g. using the ifthen package:


    \ifthenelse{\boolean{boolvar}}{show if true}{show if false}

I'm lost, however, when it comes to combining variables like that with user input from form fields. Using JavaScript and the insdljs package, I've gotten as far as hiding form fields, but not text outside of these form fields: (Note: insdljs is not part of TeX Live, but available here)


\begin{insDLJS}{mydljs}{some comment}
    function hide(){
         if(this.getField("somefield").display == display.visible){
             this.getField("somefield").display = display.hidden;
         } else{
             this.getField("somefield").display = display.visible;

        \TextField[name=somefield, width=4em]{Any way to hide e.g. this text?}

Hiding form fields like that is very handy, but I'd like to apply that to entire tables or sections. Any idea? Thanks!

share|improve this question
I can't help but I'm probably not the only person who would love to see whatever you come up with! – Andy Clifton Jun 1 '13 at 14:24
@LostBrit Thanks, but what I've been able to dig up so far seems quite disheartening. For example, in a related post the accepted answer read If you want parts of the PDF to change based on form events, you pretty much have to make those changing things read-only text fields. The topic wasn't exactly the same, though. So there is still some hope! – igorr02 Jun 1 '13 at 17:44

1 Answer 1

I don't know actually, but I conducted small research, and think that you can't hide it, you can do nothing with it, at all (without a little trick, of course)

First of all, I create a simple example and open it in Adobe Acrobat. I see, that a field and a label independent. And there is no any TextField properties that can change the label. Textfield it's field, label it's text.

If you really wanna hide label, you can do something like this:

  1. you hide field 'test', and 'tf1' is visible

  2. field 'test' is visible, 'tf1' to hide

It works, but I don't sure, that you need it.

In order to verify that we can't change the text, I have played with the buttons. Using javascript API for Acrobat Reference I found buttonGetCaption and buttonSetCaption methods, to change label (seems like caption), it works not as I expected:

console.println('value is: ';
console.println('caption is: ';
}]{\ test\ }
}]{\ \ \ \ \ \ \ }\\[0.2cm] %I didn't find as to change width. Parameter 'width' work only for fields.

before click: before after: after

So, i think it's bad idea to hide text, but you can easily hide Textfield, lets do it!


\settowidth{\mylen}{Enter name: }

\begin{insDLJS}{mydljs}{ }
function hide(){
     if(this.getField("test").display == display.visible){
          this.getField("test").display = display.hidden;
          this.getField("testLabel").display = display.hidden;
     } else{
         this.getField("test").display = display.visible;
         this.getField("testLabel").display = display.visible;
\TextField[name=testLabel,value=Enter name:,width=\mylen,readonly]{} % I don't know why but width=\whidthof and width=\the\whidthof don't work :(
\TextField[name=test]{} \\



Another solution of this problem to replace labels with defaultValue, example:

\TextField[name=test2,default=Enter something,

before click:


You can hide it as before.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.