Copy link to clipboard
Copied
Hello Everyone,
I have created two form lines. First one is tagged "PurposeOtherDetails01" and the second "PurposeOtherDetails02". Within the first tag - properties - format, I created a custom script:
if(event.willCommit||event.fieldFull) {this.getField("PurposeOtherDetails02").setFocus();}
This should push my text into the second line form when the first one is full, which works fine. I am, however, running into an issue when copying and pasting into the form rather than typing it out. You can see from my screenshot below it cuts off and does not go to the next line. Does anyone have a solution?
Side note: I am using the copy and paste method because a user will be entering details in a different UI and the software will map it onto the PDF.
Thanks!
Copy link to clipboard
Copied
So this is a custom keystroke script? not a format script.
The script only changes the keyboard focus when the user is typing and reaches the entry limit, or hits the return key. It does not split the string. Pasting text, or importing text into a form field does not simulate the user typing, which is the only way this script works. To handle pasting long text the script needs to use event.change and event.changeEx to perform the split.
Copy link to clipboard
Copied
Hey Thom_Parker,
Yes this is a custom keystroke script. I tried your method:
if(event.change&&event.changeEx) {this.getField("PurposeOtherDetails02").setFocus();}
And it is still failing. Any other functions you'd recommend to try or if I should modify my script?
Thanks!
Copy link to clipboard
Copied
Also tried if(event.change||event.changeEx) {this.getField("PurposeOtherDetails02").setFocus();}
the "or" and it does not work.
Copy link to clipboard
Copied
I think you've missed my point. You actually have to write code to split the string and place the extra text into the other field. Your original code was copied from the Acrobat JavaScript reference. At the same location in the reference the significance of event.change and event.changeEx is explained.
Do you have any experience writing code? This particular issue of automatically splitting text between fields is a thorny one with no good overall solutions. So, this is a bit of an advanced scripting task.
Copy link to clipboard
Copied
I got your point after I thought about it a little bit. Yes I do have experience writing code but yes, this one is a little tricky.
Thanks for your help!
Copy link to clipboard
Copied
Here is an article on string manipulation:
https://acrobatusers.com/tutorials/splitting-and-rebuilding-strings
You'll find more info on scripting Acrobat here:
https://www.pdfscripting.com/public/main.cfm
Copy link to clipboard
Copied
Hi Phitranpt,
Were you able to figure out how to go to the next line when copying and pasting?
Thanks,
Laura
Copy link to clipboard
Copied
Stop. Back away slowly. Don't make any sudden movements.
I've been trying to get that concept to work for over a decade. You can't. You can certainly get it working under certain ideal conditions but reliably flowing text between fields and allowing for typing, copy/paste, selecting across the fields, backspacing across fields... is just impossible in any practical sense.
I suggest you rethink your solution.
Copy link to clipboard
Copied
Absolutely true, but hey, maybe he doesn't need it to work in all situations. I mean why did Adobe provide a partial solution. Even putting code in the JS Ref for it. They must have though this was good enough, so who am I to disabuse people of the notion 😉
Copy link to clipboard
Copied
Don't use 2 fields. Use one multi-line field.
Copy link to clipboard
Copied
I was able to do this with a set of scripts.
First script, on 'got focus', joins the text from both fields, assigns it to the field you clicked on and blanks the other field.
Second script, on 'blur', determines how to split the script back into the 2 fields.
I used it for a form we had to create that came from another agency. We couldn't change the form (which had several fields too small for what needed to be typed) but we could add attached pages. When a field over-ran, it flowed to the attachment. But you can click either on the original field, or the overflow field, to edit.
I can't share the original due to confidentiality, but the attached page has 2 sets of flowing fields.