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?
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.
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.
Copy link to clipboard
Copied
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!
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...
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
LiveCicle is dead.
Adobe has discontinued this program. Those PDFs were very different than all others.
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();
}
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.
Copy link to clipboard
Copied
I found where you put it but mine doesn't seem to do anything. Any help is appreciated.
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.
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.
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.
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
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.
Copy link to clipboard
Copied
I just want to say you freaking nailed this. I have a dynamic form I wrote in JS and had to do something very similar when the client requested multiline. I got it working but it was mad clunky. You have implemented this absolutely beautifully and I'm glad to see that I at lkeast had the right solution, albeit some sloppy code.
Copy link to clipboard
Copied
Are you able to create this expanding text field functionality within InDesign or only on the PDF after it's been exported?
Copy link to clipboard
Copied
You could add it in InDesign with FormMaker.
Copy link to clipboard
Copied
Hi! Just came across this when looking for a solution to a problem I was having. I was wondering how to modify this code to expand a text box left or right? I'm working on a letterhead and I want the address/phone/fax information to move to the right if the company name gets too long. Please let me know if this is possible!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.