Highlighted

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

New Here ,
Dec 04, 2019

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?  

 

2019-12-04_13-09-32.jpg

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!

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

1.4K

Likes

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

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

New Here ,
Dec 04, 2019

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?  

 

2019-12-04_13-09-32.jpg

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!

TOPICS
Acrobat SDK and JavaScript, How to, PDF forms

Views

1.4K

Likes

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
Dec 04, 2019 0
Adobe Community Professional ,
Dec 04, 2019

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. 

Likes

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
Reply
Loading...
Dec 04, 2019 0
New Here ,
Dec 04, 2019

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!

Likes

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
Reply
Loading...
Dec 04, 2019 0
New Here ,
Dec 04, 2019

Copy link to clipboard

Copied

Also tried if(event.change||event.changeEx) {this.getField("PurposeOtherDetails02").setFocus();}

the "or" and it does not work.

Likes

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
Reply
Loading...
Dec 04, 2019 0
Adobe Community Professional ,
Dec 04, 2019

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.

Likes

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
Reply
Loading...
Dec 04, 2019 0
New Here ,
Dec 04, 2019

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!

Likes

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
Reply
Loading...
Dec 04, 2019 0
Adobe Community Professional ,
Dec 04, 2019

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

 

Likes

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
Reply
Loading...
Dec 04, 2019 0
Adobe Community Professional ,
Dec 05, 2019

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.

Likes

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
Reply
Loading...
Dec 05, 2019 1
Adobe Community Professional ,
Dec 05, 2019

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 😉

 

Likes

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
Reply
Loading...
Dec 05, 2019 0
Adobe Community Professional ,
Dec 05, 2019

Copy link to clipboard

Copied

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

Likes

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
Reply
Loading...
Dec 05, 2019 0