Skip to main content
bcs marketing
Known Participant
January 25, 2018
Answered

Move fields up if another field is empty?

  • January 25, 2018
  • 1 reply
  • 638 views

I have a 4-page form of which the 4th page is a summary of the data entered on the first 3 pages. I'm 'building' this 4th page using form fields that get their data from the other pages. While it works really well, there is one thing I'm hoping is possible:

If a field (let's say field C on page 1) is empty, it won't get shown on page 4, but there will be space 'reserved' for the data, creating a gap between fields B and D. In that case, I'd like to have all fields following field C to move up the page and 'close the gap'.

Is this possible?

This topic has been closed for replies.
Correct answer Thom Parker

Yes, it is possible. Scripts can move field locations in Acrobat/Reader. I don't know how other viewers will handle such code. They probably won't, but I know it will work in Acrobat and Reader.

The location of the field is determined by it's "rect" property. You'll need to learn about PDF page coordinates and performing simple geometry calculations.

Here is an article on page coordinates, which includes scripts for moving fields

PDF Page Coordinates (page size, field placement, etc.)

Check out the "Swat the Fly Game" and "Bouncing Button" sample files here:

Free Sample PDF Files with scripts

Both move fields. And the scripts are open for you to see.

1 reply

Thom Parker
Community Expert
Thom ParkerCommunity ExpertCorrect answer
Community Expert
January 25, 2018

Yes, it is possible. Scripts can move field locations in Acrobat/Reader. I don't know how other viewers will handle such code. They probably won't, but I know it will work in Acrobat and Reader.

The location of the field is determined by it's "rect" property. You'll need to learn about PDF page coordinates and performing simple geometry calculations.

Here is an article on page coordinates, which includes scripts for moving fields

PDF Page Coordinates (page size, field placement, etc.)

Check out the "Swat the Fly Game" and "Bouncing Button" sample files here:

Free Sample PDF Files with scripts

Both move fields. And the scripts are open for you to see.

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often