7 Replies Latest reply on Jan 1, 2012 10:54 AM by maxwyss

    How do you collapse a blank area of a pdf form?


      I'm new to acrobat x pro and javascript, and am working on a Mac.  I'm working on a form that has hidden fields that become visible when an item is choosen in a drop down box.  When the fields are hidden there is a large white area where the fields are with permanantly visible are half way down the page.  I would like those fields to be moved up until the drop box selection is made.


      How do I collapse this white area where the hidden fields are until they corresponding item is choosen from the drop down?   Once the hidden fields are visible the permanantly visible fields are moved back down the page?


      Any help would be really appreciated!!!

        • 1. Re: How do you collapse a blank area of a pdf form?
          DimitriM Level 3

          Hi cane00019,


          In order to have the type of dynamic feature you describe, you need to create your PDF form in LiveCycle Designer, not Acrobat X.  This can't be done in an AcroForm (created in Acrobat).  Unfortunately, LiveCycle Designer is a WIndows only program.


          Hope this helps,



          WindJack Solutions



          • 2. Re: How do you collapse a blank area of a pdf form?
            maxwyss Level 4

            With all due respect, Dimitri, it can be done in AcroForms. It requires a little bit of programming, but it is possible and it is in productive use.


            Max Wyss.

            • 3. Re: How do you collapse a blank area of a pdf form?
              George_Johnson MVP & Adobe Community Professional



              I directed him here so you would show him how to do it.


              Happy New Year!

              • 4. Re: How do you collapse a blank area of a pdf form?
                try67 MVP & Adobe Community Professional

                Basically all that needs to be done is to loop over these fields and change their location on the page. Here's a simple example that shows how to move 3 fields up or down based on a drop-down selection. Let's say that if the user selects "A" you want to push the fields down the page by 100 points, but if they select "B" you want to return them to their previous postions. The fields we want to move are called "Text1", "Text2", "Text3".

                The code below is the custom Validate script for the drop-down.


                var fieldsToMove = ["Text1","Text2","Text3"]

                var offset = 100;


                for (var i in fieldsToMove) {

                    var f = this.getField(fieldsToMove[i]);

                    var oldRect = f.rect;

                    var newRect;

                    if (event.value=="A")

                        newRect = [ oldRect[0], oldRect[1]-offset, oldRect[2], oldRect[3]-offset ];

                    else if (event.value=="B")

                        newRect = [ oldRect[0], oldRect[1]+offset, oldRect[2], oldRect[3]+offset ];

                    f.rect = newRect;


                • 5. Re: How do you collapse a blank area of a pdf form?
                  DimitriM Level 3

                  Hi cane00019,


                  As per Max et al, I stand corrected ( not the first time it's happened ).  You can move fields around pretty much however you want with some scripting, and if the form is designed so that no static content will be in the way when the fields are moved into their new position, this is definitely doable.


                  Sorry to cause any confusion with my first reply.


                  Happy New Year!



                  WindJack Solutions



                  • 6. Re: How do you collapse a blank area of a pdf form?
                    Thom Parker Adobe Community Professional

                    There are a couple of things to be aware of when using the technique outlined by Mr 67.  The first is that static content, such as the field labels, must also be placed in fields.  Scripting cannot be used to move page text or graphics.  If there are graphics, then those graphics can be placed in either a custom stamp, or as the image on a button field.  You can also make creative used of the drawing annotations, such as lines.  All fields and markups are movable using the technique outlined above, although the annotations are aquired differently.


                    The second bit to worry about is getting the order of the change correct.  The code above uses a relative position offset, it assumes an initial postion for all the field.  It also assumes that A and B are always selected one after the other, i.e. that they are the only entries on the list.  For example, If there was a C selection then it is possible to select "B" twice without selecting "A".  There are also other situations where the entries can be selected out of order. A more robust strategy is  to test  the field position before moving it.  Only the first field postion needs to be tested.


                    Thom Parker
                    The source for PDF Scripting Info


                    The Acrobat JavaScript Reference, Use it Early and Often


                    Then most important JavaScript Development tool in Acrobat
                    The Console Window (Video tutorial)
                    The Console Window(article)

                    • 7. Re: How do you collapse a blank area of a pdf form?
                      maxwyss Level 4

                      I fully agree; nobody says that it would be easy to do. And you should have a little bit of a clue of what you are doing…


                      And, to be fully dynamic, you will have to put everything into fields (labels, base text, etc.).


                      In many cases, it is easiest to completely refresh the page when such dynamic actions are triggered. On the positive side, it normally happens when users don't mind if it takes a few moments.


                      Hope this can help.


                      Max Wyss.