Skip navigation
Currently Being Moderated

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

Dec 31, 2011 2:10 PM

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!!!

 
Replies
  • DimitriM
    172 posts
    Dec 11, 2007
    Currently Being Moderated
    Dec 31, 2011 4:17 PM   in reply to cane00019

    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,

     

    Dimitri

    WindJack Solutions

    www.windjack.com

    www.pdfscripting.com

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2012 12:10 AM   in reply to DimitriM

    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.

     
    |
    Mark as:
  • George Johnson
    11,676 posts
    Aug 11, 2002
    Currently Being Moderated
    Jan 1, 2012 12:38 AM   in reply to maxwyss

    Max,

     

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

     

    Happy New Year!

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2012 6:53 AM   in reply to cane00019

    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;

    }

     
    |
    Mark as:
  • DimitriM
    172 posts
    Dec 11, 2007
    Currently Being Moderated
    Jan 1, 2012 10:45 AM   in reply to cane00019

    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!

     

    Dimitri

    WindJack Solutions

    www.windjack.com

    www.pdfscripting.com

     
    |
    Mark as:
  • Thom Parker
    216 posts
    Jul 16, 2003
    Currently Being Moderated
    Jan 1, 2012 10:51 AM   in reply to Gilad D (try67)

    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
    pdfscripting.com

     

    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)

     
    |
    Mark as:
  • Currently Being Moderated
    Jan 1, 2012 10:54 AM   in reply to Thom Parker

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points