Before we converted to Aspose.Words, our custom merging tool would accept the following merge field definitions with line breaks (\br). Merging with Aspose.Words doesn’t recognize that syntax.
Is there something with which I can replace the \br\ so I can pass a line break to Word?
Hi Alexey. Thank you for your quick response. I tried both of those (see sample below) but it just incudes the text of the line break characters in the Word document. I need to just insert the line break in my merge field definitions as shown in my code, but neither example seems to work. Thank you again!
@wrowell1 Could you please attach you template, output document and full code that will allow us to reproduce the problem? I have tested with a simple template and the following code and line breaks are processed properly:
string[] names = new string[] { "Test" };
string[] values = new string[] { "This is multiline\vtext with soft\vlinebreak" };
Document doc = new Document(@"C:\Temp\in.docx");
doc.MailMerge.Execute(names, values);
doc.Save(@"C:\Temp\out.docx");
Here is input and output documents: in.docx (12.0 KB) out.docx (9.4 KB)
Hi Alexey. I’m afraid I’m still getting the “\v” in the merge document instead of a line break. I’m attaching both my merged Word document and the VB code that’s used to generate the merge field names and values. On line 67 of the text file is where I’ve place the “\v” in between the values. Maybe you’ll see something that I’m doing wrong.
@wrowell1 Thank you for additional information. Escape sequences does not work in VB strings. You should use ControlChar.LineBreak, like shown in the following code:
Dim names As String() = New String() {"Test"}
Dim values As String() = New String() {"This is multiline" + ControlChar.LineBreak + "text with soft" + ControlChar.LineBreak + "linebreak"}
Dim doc As Document = New Document("C:\Temp\in.docx")
doc.MailMerge.Execute(names, values)
doc.Save("C:\Temp\out.docx")