Move Acrobat Image Fields and Update Selected Array Values
Question details
Move an Acrobat image field by changing its rectangle coordinates and update only selected values in an array.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Editing a PDF form with Acrobat JavaScript while preserving array values that do not need to change.
- Observed behavior
- The image field moves to the desired position, and only the specified array indexes are updated.
Open the PDF in Acrobat and confirm that the image is a form field, not a static page image. In Prepare a Form, check the field's exact name and ensure JavaScript is enabled.
Change the field rectangle and selected array indexes
Use Acrobat JavaScript to shift a form field horizontally and modify specific array elements.
A field's rect array contains its left, top, right, and bottom coordinates. Increasing both horizontal coordinates by the same amount moves the field right without changing its width; coordinates are measured in PDF points.
In Acrobat, open the PDF and choose All tools > Use JavaScript > JavaScript debugger. The menu name or location may vary by Acrobat version.
In the console, replace Image1 with the exact field name and run: var f = this.getField("Image1"); var r = f.rect; r[0] += 5; r[2] += 5; f.rect = r; This moves the field 5 points to the right.
In the script where newPos is defined, add: newPos[0] += 1; newPos[2] += 1; Only indexes 0 and 2 are changed; the remaining elements retain their values.

View PDFs and edit Office files with WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for viewing PDFs and working with Office files. Its format compatibility makes it easy to bring existing documents into your workflow. Use Acrobat for the field-specific JavaScript changes described above.

Frequently Asked Questions
How do I move the field to the left instead?
In the Acrobat JavaScript console, subtract the same amount from rect indexes 0 and 2, then assign the modified array back to the field's rect property.
Why do I need to assign the rectangle back to the field?
After changing the coordinates in the local array, use f.rect = r to apply the modified rectangle to the Acrobat form field.
Will changing indexes 0 and 2 affect the other array values?
No. Statements such as newPos[0] += 1 and newPos[2] += 1 change only those elements, provided the rest of the script does not modify the array.
Can this method move a static image on a PDF page?
No. The getField and rect method applies to form fields. For a static page image, use Acrobat's PDF editing tools instead.




