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

Insert paragraphs in a bookmark

Thread ID:





104314 Jul 10,2012 09:11 AM UTC Jan 19,2014 03:39 PM UTC ASP.NET Web Forms (Classic) 7
Tags: DocIO
Asked On July 10, 2012 09:11 AM UTC



I'm using Syncfusion Essential v10.2.0.75 to generate word document and I have some trouble inserting paragraphs in bookmarks. I'm totally new to Syncfusion so maybe I misunderstood something...


I've created a dotx template which contains some text and bookmarks. The section where I want to insert paragraph is as follow :

[template hard coded text]


[template hard coded text]


So the bookmark is on a new line, just between two lines of text (no other character on the line with the bookmark).

To create my document (based on my template) I use the following code :

Stream templateStream = templateFile.OpenBinaryStream();

WordDocument document = newWordDocument();

document.Open(templateStream, Syncfusion.DocIO.FormatType.Word2010Dotx);


And to insert my paragraphs :

BookmarksNavigator bk = newBookmarksNavigator(document);

bk.MoveToBookmark("[Bookmark name]");

List<string> skills = GetSkills();foreach(string str in skills)


IWParagraph paragraph = document.CreateParagraph();


       paragraph.ListFormat.ListLevelNumber = 0;

       IWTextRange textRange = paragraph.AppendText(str);




My problem is that a new line is added before the first paragraph and an other one after the last paragraph.

So instead of having (as i expected) :

[template hard coded text]



[template hard coded test]


I have the following result :

[template hard coded text]





[template hard coded text]


If I insert text using bk.InsertText() method there is no extra line break, but as far as i understand I need to insert paragraphs to display a bullet list.

Am I missing something ?

Thanks for your help

Ramkumar M [Syncfusion]
Replied On July 12, 2012 09:48 AM UTC

Hi Acorah

Thank you for your interest in Syncfusion product s

As per behavior of DocIO object model, it is not possible to insert a paragraph into another paragraph, so in InsertParagraph function we have split BookmarkStart and BookmarkEnd into two paragraphs and then insert the new paragraph in between those two paragraphs. That is the reason for new line before and after the inserted paragraphs.

However we have created the sample to meet your requirement by handling in object level. Please do find the sample from the attachment. Try running the sample and let us know if this helps you.

Please let us know if you have any other questions.



Replied On July 12, 2012 01:15 PM UTC

Hi Ramkumar,
Thanks for your reply, I tested your code and it works like a charm. It even solved my second problem I had not seen when I posted my first message. My paragraphs were inserted in the wrong order, and appeared from last to first in my bulleted list. So I had something like the following as result :
    Item 2.2
    Item 2.1
Item 2
    Item 1.1
Item 1
But with your code evrything is good, thanks for saving my day :)

Ramkumar M [Syncfusion]
Replied On July 13, 2012 04:47 AM UTC

Hi Acorah,

You're welcome. Please let us know if you have any other questions.



Julien Charles
Replied On January 16, 2014 10:54 AM UTC

I am really interested in your solution you provide because I have the same problem. But I can't download the zip file with the code (Access denied). Is it possible to have the access again or to view the sample code ?

Thanks for your help

Sathish K [Syncfusion]
Replied On January 17, 2014 12:08 PM UTC

Hi Julien,


Thank you for your interest in Syncfusion products.


You can remove the empty paragraph which is preserved after the replaced content by finding out that paragraph manually (which contains the BookmarkStart and BookmarkEnd items).


Alternatively you can replace the bookmark by a text body item which contains the item to be replaced like paragraph, picture, etc., we have prepared a sample to illustrate both of the scenarios. Please find the attached sample and let us know if this helps you.


Please let us know if you need any further assistance.





Julien Charles
Replied On January 17, 2014 01:23 PM UTC

 It works great and my problem is solved.
Thank you for your reactivity and your answer !

Sathish K [Syncfusion]
Replied On January 19, 2014 03:39 PM UTC

Hi Julien,


Thank you for your update.


Please let us know if you need any further assistance. We will be happy to assist you as always.





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

or the page will be automatically redirected to 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