Skip to main content
Inspiring
October 13, 2017
Question

Text wrapping not occurring in multiline text field with CRLF chars

  • October 13, 2017
  • 6 replies
  • 5773 views

I've scoured this forum and google trying to resolve a data formatting issue in a multiline text field.

I have an editable PDF document with multiple multiline text fields all with the same settings (see pic "multiline text field settings.png" below)

An example data used to populate one of these form fields plus the actual data whereby I know the "\r\n" is being translated into "CRLF" (proved using Notepad++).

multiline text field settings.pngSample inputData In Form Field
Shortness of breath - normal activities\n\nSleep Apnoea\r\nDisturbed sleep\r\nSnoringLung Condition:\r\nRequires Home Oxygen\r\nCurrent / Ex smoker (circle)\r\n

What I'm seeing in the populated document  vs what I want to see is shown in the table below. The screengrabs are from the same document, one where it's just been generated in the browser, the second where it's generated in the browser but I've clicked in and away from the field, and the third after saving the document locally. What I want is to consistently have what is presented in the middle image without having to click into the form field. Also upon saving it should not revert back to the single line non-wrapped output.

Just Generated

in browser

Click in & Out of

field whilst still

viewing in browser

** target display  **

Post file-save viewing

viewing in Adobe

Reader

I've spent half a day so far scouring for answers, recreating the form fields, changing the field settings on/off, changing font type and size.

And I know when I manually enter data into this field (ie via Adobe Acrobat Pro or Adobe Reader) the correct behaviour occurs. It's only when I'm programmatically populating that I get this issue.

I've even taking this very form that's been filled in, changed the settings so the correct behaviour is displayed, cleared the content, and used that as my new baseline form to populate, but alas no change.

Using: Win 8, Adobe Acrobat XI Pro

This topic has been closed for replies.

6 replies

BigWinnieAuthor
Inspiring
November 6, 2017

Something I've noticed since. I have run the Preflight test "Form field does not have appearance dict" which has resulted in showing that the multi-line text fields are missing their appearance dictionary. Now I have not found a way to recreate this appearance dictionary other than by allowing Adobe Acrobat Pro to create the fields in the document when no other fields exist, then duplicating the fields where I need another multiline-text field.

Anyone else know how to recreate missing appearance dictionaries for form fields by other means? If so, feel free to add to this post.

BigWinnieAuthor
Inspiring
October 17, 2017

What I have not yet shared, silly me, was this issue has appeared working with Chrome (Version 61.0.3163.100 (Official Build) (64-bit)) as the browser in which the PDF is presented.

I have subsequently tried this on Internet Explorer 11, and funny enough the problem disappears, either because the Page/Open javascript runs, or because the browser somehow resolves the appearance issue.

Unfortunately IE is not supported with Salesforce post Dec 2017 so this is not a viable long term option.

Currently I'm left with the save the file locally, open the file to cause the javascript to run, and then save the document again; crude but works.

Legend
October 17, 2017

IE uses Acrobat Reader, so the JavaScript is run. Non Adobe viewers like Chome MIGHT have JavaScript support and MIGHT include the methods you use which MIGHT have an effect. They MIGHT ignore appearances completely. Indeed they MIGHT (and often do) completely ignore form fields. All bets off with non-Adobe software.

Legend
October 16, 2017

This will work... But only if the PDF is opened by a viewer that handkes JavaScript. So.. A solution for yourself and a solution if you are fixing the files to distribute, but not a solution if you distribute the files directly.

BigWinnieAuthor
Inspiring
October 16, 2017

Thank you Test Screen Name​, this echoes my experience whereby I've been unable to get the app doing the generation to fire the javascript function either directly or through any Action. Hmm, what to try next, of that I'm unsure.

Ideas anyone?

BigWinnieAuthor
Inspiring
October 16, 2017

I'm also putting this javascript code snippet out there as it might help others (and a place for me to find it again). It's what I've tried to use to change the appearance based on different Actions. This loops through all the form fields in the document seeking multiline text fields. It then takes a copy of the current data value of the field, changes the multiline setting to reset it, then puts the data back in case the data in the field was corrupted by the multiline setting change.

for (var i = 0; i <= this.numFields; i++){

     var fld = this.getField(this.getNthFieldName(i));

     if(fld != null) {

          if ( fld.type == "text" ) {

               if ( fld.multiline == true) {

                         var mv = fld.value;

                         fld.multiline = false;

                         fld.multiline = true;

                         fld.value = mv;

               }

          }

     }

}

Bernd Alheit
Community Expert
Community Expert
October 13, 2017

How do you populate the form?

BigWinnieAuthor
Inspiring
October 13, 2017

Currently this is being generated via Salesforce using an app called Vlocity.

I've reached out to Vlocity support also for assistance.

I've also written some javascript for use internal to the document that is called on various actions Will Close|Print|Save and Page/Open. The script loops through all the form fields seeking out multiline text fields, resetting the multiline attribute False|True and pasting the data back again. Outside of Salesforce PDf rendering this fixes the problem.

Now also trying to get SF to fire the javascript.

Ideally though I don't want this javascript in the doc but get the data to wrap properly on the CRLF chars.

Bernd Alheit
Community Expert
Community Expert
October 13, 2017

Looks like a problem of this app.

BigWinnieAuthor
Inspiring
October 13, 2017

I should also mention that I've tried playing around the CRLF chars using "\r", "\n", "\r\n", "\r\r", and "\n\n" to see if that may cause a change in the presentation experience.