Others

Move Acrobat Image Fields and Update Selected Array Values

Maira MehtabMaira Mehtab Nov 18, 2026 869 views

Question details

Move an Acrobat image field by changing its rectangle coordinates and update only selected values in an array.

Move Acrobat Image Fields and Update Selected Array Values
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the JavaScript console

In Acrobat, open the PDF and choose All tools > Use JavaScript > JavaScript debugger. The menu name or location may vary by Acrobat version.

2
Move the image field

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.

3
Update the selected indexes

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.

Change the field rectangle and selected array indexes
Check the field name: If getField returns null, verify the field name in Prepare a Form. The PDF must also permit the intended form edits.
Free Microsoft Office alternative

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.

Open and view PDF documents alongside your Office filesWork with Microsoft Office formats, including DOCX, XLSX, and PPTXNavigate documents with a familiar, easy-to-use interfaceUse a lightweight suite with free core tools
QA img-9

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.