Move PDF Form Fields Up When a Section Is Hidden in Adobe Acrobat
Question details
Move a later section of a PDF form upward when conditional fields in the preceding section are hidden.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- A PDF form displays additional fields when the user selects Yes and hides them when the user selects No.
- Observed behavior
- Selecting No hides the conditional fields but leaves a blank area before the next section.
Open the form in Acrobat and identify the names of the conditional fields and every field that must move. Note their original positions and check whether section labels are form fields or fixed PDF content.
Use Acrobat JavaScript to reposition the following form fields
Use this approach when the form must change layout automatically after a Yes or No selection.
Hiding a field does not automatically reflow a PDF. Acrobat JavaScript can change a form field's rect property, using coordinates in the order [left, top, right, bottom]. Increasing both vertical coordinates moves a field upward without changing its height.
The example uses one conditional field and one following field. Repeat the visibility and position changes for all affected fields. Fixed page text and graphics cannot be moved with a form field's rect property; edit the page layout or use suitable form fields for content that must move.
In Adobe Acrobat, open the PDF and choose All tools > Prepare a form. Check the field names in the form editor and replace the example names in the script with your own.
Open Properties for the No radio button, select Actions, choose Mouse Up and Run a JavaScript, then select Add. Enter: var show = false; var conditional = this.getField("ConditionalField"); var following = this.getField("NextField"); conditional.display = show ? display.visible : display.hidden; following.rect = show ? [72, 400, 250, 380] : [72, 480, 250, 460];
In Properties > Actions for the Yes radio button, add the same Mouse Up JavaScript but change the first statement to var show = true. This shows the conditional field and returns the following field to its original position.
Replace both example coordinate arrays with positions appropriate for your form, preserving each field's width and height. Save the PDF, exit form editing, and select Yes and No to check the layout in an Acrobat viewer with JavaScript enabled.

Work with PDFs and Office files in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for working with PDFs and Office documents. It can help with general PDF editing, but it does not fix or guarantee support for Acrobat JavaScript that dynamically moves form fields.

Frequently Asked Questions
Why does a blank space remain after I hide a PDF form field?
A PDF form does not automatically reflow when a field is hidden. Use Acrobat JavaScript to update the rect coordinates of the fields below it, or redesign the page layout.
How do I move a form field upward without resizing it?
In the field's rect array, increase both the top and bottom coordinates by the same amount while leaving the left and right coordinates unchanged.
Can the script move a section heading as well?
It can reposition the heading if the heading is a form field. Fixed PDF page text is not a form field, so it must be edited in the page layout or replaced with suitable movable content.
Will the form work in every PDF viewer?
Not necessarily. Some viewers limit or do not support Acrobat JavaScript and field repositioning. Test the Yes and No actions in the PDF viewers your recipients use.




