Hello,
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]
bookmark
[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.ApplyDefBulletStyle();
paragraph.ListFormat.ListLevelNumber = 0;
IWTextRange textRange =
paragraph.AppendText(str);
bk.InsertParagraph(paragraph);
}
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]
skill1
skill2
[template hard coded test]
I have the following result :
[template hard coded text]
skill1
skill2
[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
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.
Regards,
Ramkumar
Hi
Acorah,
You're welcome. Please let us know
if you have any other questions.
Regards,
Ramkumar
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.
Regards,
Sathish
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.
Regards,
Sathish