Skip to main content
December 4, 2019
Question

Custom Format Script. Go to new line when full utilizing copy and paste method.

  • December 4, 2019
  • 4 replies
  • 9609 views

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!

This topic has been closed for replies.

4 replies

New Participant
April 16, 2021

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. 

 

Bernd Alheit
Braniac
December 5, 2019

Don't use 2 fields. Use one multi-line field.

Joel Geraci
Inspiring
December 5, 2019

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.

Thom Parker
Inspiring
December 5, 2019

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 😉

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Thom Parker
Inspiring
December 4, 2019

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. 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
December 4, 2019

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!

December 4, 2019

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.


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!