We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

.docx generation and line breaks

Thread ID:





94663 May 26,2010 09:54 AM UTC May 28,2010 04:48 AM UTC ASP.NET Web Forms (Classic) 3
Tags: DocIO
Alexandre Gex
Asked On May 26, 2010 09:54 AM UTC

Hi everyone,

I am using DocIO to generate word documents.
The process is the following :
- the user selects a word model (.doc or .docx)
- the program detects some specific strings and replace them by data stored in a database (method Replace of WordDocument class)
- the new document is saved (method Save of wordDocument class)

The process is working perfectly when the program generates a .doc, but when a .docx is generated, there is a problem with line breaks.
Indeed, the file is generated, but i can't open it : i get an error "invalid xml character".

I am using the string "\v" to insert line breaks in documents.
If i replace it by "\n", "\r", or "\r\n", i get a openable document, but these strings are not line breaks, so it's not an acceptable solution for me.

So my question is simple : what string do i have to use to insert a line break in a .docx ? I'm sorry if my question seems very basic, but i don't understand why "\v" is causing problems in .docx, and not in .doc...

Thanks in advance for your help.


Rajendran [Syncfusion]
Replied On May 26, 2010 10:55 AM UTC

Hi Alexandre,

Thank you for using Syncfusion products.

For inserting line break in word document please refer the following code snippet:
Code Snippet:
IWParagraph paragraph = section.AddParagraph();

Similarly you can insert column break and page break.

Please try this and let us know if you have any other questions.


Alexandre Gex
Replied On May 27, 2010 12:34 PM UTC

Hi Rajendran, and thanks for your response.

I saw the code you mention in the Syncfusion documentation.
However, I think i cannot use that because i'm just using the method Replace of WordDocument class.

Typically, in my code, I have something like :

WordDocument doc = new WordDocument("inputDoc", FormatType.Docx);
doc.Replace(new Regex("something", RegexOptions.IgnoreCase), "strReplacement");
doc.Save("outputDoc", FormatType.Docx);

The only thing i'd like to do is to insert a line break in "strReplacement". "str\vReplacement" is working in .doc, but not in .docx...

I hope i've exposed my problem more precisely.


Rajendran [Syncfusion]
Replied On May 28, 2010 04:48 AM UTC

Hi Alexandre,

Thank you for your update.

We have forwarded this issue to our development team for further analysis.

Could you please report this issue through Direct Trac Developer Support System
https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take
the advantage of the expertise of a dedicated support engineer and a guaranteed response time and
we hope you will take advantage of this system as well. If you have already reported, please ignore this.

Please let us know if you have any other questions.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon