Get new line character from WTextFormField

I am reading a docx form with WTextFormField and the text entered by user has new line characters, but when I read the values I get the text without new line characters. Everything is concatenated in one long line.
If I open the word document in Office, and select the text, and paste in notepad, the new line characters are there, so why can't I do this with Syncfusion ?



2 Replies

DS Dharanya Sakthivel Syncfusion Team June 18, 2024 04:32 PM UTC

Michael, based on the information provided, we understand that your requirement is to retrieve user entered text, including new line characters, from a WTextFormField. We will create a sample to address the reported issue and provide more details on following days.

Regards,
Dharanya




SB Suriya Balamurugan Syncfusion Team June 19, 2024 03:48 PM UTC

Michael,

The Syncfusion Word (DocIO) library doesn’t have a direct API to get the text with newline characters from a TextFormField.

As a workaround, while adding the TextFormField to the Word document, a bookmark is added to it by default. Using this bookmark, we can get the text with newline characters.

To achieve this, we have prepared a sample application, which can be downloaded from the attachment below.

In this sample, we have done the following:
  1. Opened a Word document containing a TextFormField.
  2. Retrieved the bookmark name of the TextFormField.
  3. Extracted the bookmark content as a Word document.
  4. Extracted the text from the Word document.
  5. Now the TextFormField text contains newline characters.

Please refer to our UG documentation link to know about find item by property,
Find item by property

Please refer to our UG documentation link to know about how to retrieve the specified bookmark content in a Word document,
Retrieving contents within a bookmark


Attachment: GetmultilinetextfromTextFormField_93d5f997.zip

Loader.
Up arrow icon