Carrige return recognition in a table

Data:
CoName= ABC COMPANY
Addr = ADDR 1
ADDR 2
Tel = 123

Template: (Table of 3 rows)
-----------------------------
MERGEFIELD CoName |
MERGEFIELD Addr
MERGEFIELD Tel
-----------------------------

The merged output is incorrect:
-----------------------------
ABC COMPANY |
ADDR 1 ADDR 2 |carriage return of the Addr field not recognized.
123 |
-----------------------------

However if the template is changed to:
-----------------------------
MERGEFIELD CoName |
MERGEFIELD Addr | to leave a line below
|
MERGEFIELD Tel |
-----------------------------

Then the carrage return is recognized.
-----------------------------
ABC COMPANY |
ADDR 1 |
ADDR 2 |
|BUT there is a unwanted row here.
123 |
-----------------------------

Please help…

Thanks,
Ben

I think this or similar problem was fixed a couple of releases ago. It was due to text had #13#10 characters combination whereas in Word only #13 makes sense. Aspose.Word now automatically removes converts #13#10 in user’s data. Make sure you use the latest version and if the problem stil persists check what is your “carriage return” actually. It should be either just #13 or #13#10.

Ok, I’ve got your files and tested them. There seems to be a problem that carriage return inside field data is not recognized when the field is in a table cell and has no carriage return after it, but just end of cell mark.

I think there is an easy workaround that will help you:
Just add a carriage return (not a new line) after the address field and all will work okay. You might wish to switch hidden characters on in Word to be sure what goes where.

So your cell should look like:

CompanyName
Address

Let me know if that works for you.

Ok, I’ll put a carriage return for this situation.

The only scenario when it is not preferable is when users do not want the exta line caused by the carriage return, and I can’t get a way around it. I’ll let you know when that occur.

Should be alright for the moment.

Thanks,
Ben

Here’s what I did:

value = value.Replace(StringConstants.NL, StringConstants.NewLineForMsWord);

Where the StringConstants.NL and StringConstants.NewLineForMsWord constants were defined as follows:

/// 
/// A new line.
/// 
public static readonly string NL = Environment.NewLine;
/// 
/// A new line character in MS Word (which is char(13))
/// 
public static string NewLineForMsWord
{
    get
    {
        if (m_newLineForMsWord == null)
        {
            Byte[] myBytes13 = { 13 };
            m_newLineForMsWord = System.Text.Encoding.ASCII.GetString(myBytes13);
        }
        return m_newLineForMsWord;
    }
}

private static string m_newLineForMsWord;

Hi
Thanks for your inquiry. You can also use ControlChar.ParagraphBreakCharacter. See the following link for more information.
https://reference.aspose.com/words/net/aspose.words/controlchar/paragraphbreakchar/
Best regards.

We are running into the same problem when a “carriage return inside field data is not recognized when the field is in
a table cell and has no carriage return after it, but just end of cell
mark.”.

The workaround of adding a carriage return after the field works fine but our users are not happy with the extra line this produces.

Has this problem been fixed in version 6.3 (we are running Aspose.Words for .NET 6.2.0)?

If not, are there plans to fix this in a future release?

Cheers.

Hi

Thanks for your request. Could you please attach your template and code for testing? I will investigate your issue and provide you more information.
Best regards.