• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to create an expandable interactive text box for PDF

New Here ,
Feb 09, 2023 Feb 09, 2023

Copy link to clipboard

Copied

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?

TOPICS
How to

Views

18.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2023 Feb 09, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 09, 2023 Feb 09, 2023

Copy link to clipboard

Copied

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

2023-02-09_16-16-50.png

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Feb 10, 2023 Feb 10, 2023

Copy link to clipboard

Copied

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();
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

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. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 02, 2023 Nov 02, 2023

Copy link to clipboard

Copied

If you could upload your PDF that might be helpful.

Note the line:  theFields = ["Text Field 2", "Text Field 3"];

Make sure that in your own document, the 2 fields are also called, exactly, Text Field 2 and Text Field 3, or else change that line to match the names of your fields.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 16, 2023 Nov 16, 2023

Copy link to clipboard

Copied

Hi I just came accross this example as I have a very similar requirement. Your example worked erfectly! Thank you for that! I have a multi page form. I need a way to exapnd the text fileds and flow to the next page if the text field is the last field on the form and all the subsequent fileds in this page and the rest of the paged need to be pushed down. . If the text field that is expanding is in the middle of the form, all subsequent fileds need to be pushed down accordingly and fileds need to flow thru the next page as necessary. Could you help me with that. And also what if the pages have footnotes, how to handle that. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 21, 2023 Nov 21, 2023

Copy link to clipboard

Copied

Yeah if you could share how to expand to mulitple pages that would be great! I have a 4 page form that would benefit from this but it would get very messy if it didn't add pages too

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 22, 2023 Nov 22, 2023

Copy link to clipboard

Copied

Adding pages adds a level of complexity.

First of all, it requires "template" pages, as plain Acrobat scripting doesn't allow adding pages to a PDF otherwise.

Then, you need to add all the scripting logic that tests if the current fields exceed the page boundary, and to move the relevant fields to the next page if so (and move any subsequent fields to further pages).

Footnotes would normally be static in a PDF, so the page boundary would need to marked to end just before the footnotes.

It's doable, but involved.

I can't offer a free solution, but would be very happy to add this interactivity to your form. Contact me for a quote.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 19, 2023 Dec 19, 2023

Copy link to clipboard

Copied

LATEST

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. 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines