Skip to main content
artsoftorri
Participant
Feb 9, 2023 8:53 PM UTC
Question

How to create an expandable interactive text box for PDF

I just finished creating an interactive pdf but the text boxes I created wont expand when the text box is full, it keeps going but wont to the next line (I dont know how to explain it). Is there a way to have an expandable interactive text box or would I need to use another app?

23 replies

Participant
Apr 24, 2024 12:45 PM UTC

What I find sad is that LiveCycle (XFA) does this VERY WELL! However, Adobe (and Mac) have decided for some reason not to incorporate WONDERFUL product into something REALLY useful.

 

Browser based readers can't work with XFA.
Windows users can flatten XFA forms by printing to PDF, but MAC has removed the ability to do that.

 

It is really a shame. I did some pretty amazing things with expanding fields/documents, multiple pages, and (with some help from iText) form reading/manipulation. This unwillingness to allow others to access XFA forms really is unfortunate. They have unnecessarily limited their product.

Translate
Participant
Dec 19, 2023 2:25 PM UTC

This was easy to do in Adobe Livecycle. However, that product was decommissioned to make way for AEM which is not really affordable for most. 

 

Translate
TᴀW
Legend
Feb 10, 2023 1:48 PM UTC

Here's a proof-of-concept. It's quite cool in a geeky way 8-)

The attached PDF has 2 text fields that expand as needed to accommodate the text. As the top field expands, it pushes the rest of the form down.

To see how this is done, take a look at the custom keystroke script attached to the text fields (copied below).

This has been tested and works in Acrobat. It requires a PDF reader with full Javascript support (like the free Adobe Reader on desktop).

 

if ( event.fieldFull )
{
	theFields = ["Text Field 2", "Text Field 3"];
	// Move other fields down
	for (i = 0; i < theFields.length; i++){
		f = this.getField(theFields[i]);
		b = f.rect;
		b[1] -= 20;
		b[3] -= 20;
		f.rect = b;
	}
	// Enlarge active field
	f = event.target;
	b = f.rect;
	b[3] -= 20;
	f.display = display.hidden;
	f.rect = b;
	event.change = event.changeEx;
	f.display = display.visible;
	f.setFocus();
}

 

Translate
id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
Participant
Nov 2, 2023 4:51 PM UTC

Can I ask where this code goes when creating the expandable PDF? I'm not a "coder". I have a PDF that I 'm testing and I can't seem to figure out where exactly to put the script. Thank you. 

Translate
Participant
Nov 2, 2023 4:57 PM UTC

I found where you put it but mine doesn't seem to do anything.  Any help is appreciated. 

Translate
TᴀW
Legend
Feb 10, 2023 8:17 AM UTC

It is possible by attaching some Javascript to the format event of the text field.

As the user types, you would keeping checking whether the field overflows, and if it does, expand it (modify its coordinates).

It's a little trickier to shrink the field as needed (because then there is no overflow, so how to know it's not filled?)

I don't have the Javascript to hand, and will try to post it later. I have played around with it in the past, and it is a little messy -- I think there was a problem of the input cursor jumping to the beginning of the field when the field was expanded.

Also, unless this is the last field in the form, what will you do if fields start overlapping. And what will you do if you reach the bottom of the page? (Again, these issues could be solved by reprogramming the coordinates of all the other fields, I guess).

I'll try to post something later, but it's a bit of a messy solution, I think...

Translate
id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
BobLevine
Community Expert
Community Expert
Feb 10, 2023 12:48 PM UTC

Messy is probably an understatement. I intentionally didn't mention trying that because another scenario is having multiple fields doing this. It's one of those things that I would file under "just because you can, doesn't mean you should."

This type of thing is best reserved for responsive forms on websites.

Translate
Participant
Apr 24, 2024 12:43 PM UTC

What I find sad is that LiveCycle (XFA) does this VERY WELL!  However, Adobe (and Mac) have decided for some reason not to incorporate WONDERFUL product into something REALLY useful. 

Browser based readers can't work with XFA.
Windows users can flatten XFA forms by printing to PDF, but MAC has removed the ability to do that.

It is really a shame.  I did some pretty amazing things with expanding fields/documents, multiple pages, and (with some help from iText) form reading/manipulation.  This unwillingness to allow others to access XFA forms really is unfortunate.  They have unnecessarily limited their product. 

Translate
BobLevine
Community Expert
Community Expert
Feb 9, 2023 9:18 PM UTC

Set your text field up to be multiline and scrollable. There is no way to make the text field expand.

 

Translate
Participant
May 28, 2024 1:01 PM UTC

Bob, it's so helpful when one needs an answer to a problem, and someone posts a simpledescription with a screenshot. Thanks, Amigo! My text fields are now multiline!

 

Translate
Derek Cross
Community Expert
Community Expert
Feb 9, 2023 9:15 PM UTC

You create your form in InDesign and fine tune it in Acrobat Pro.
You can't expand the size of the Text field once it's created but you can change the properties to multi-line and scroll long text so you can get more text in the field (you can limit the number of characters in the field too) . Do this under the Options tab in Text Field Properties in Acrobat Pro.

Translate