Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Tue Apr 24, 2018 12:15 pm
Hello,
I have a word template with many bookmarks and I would like to know how to insert texts in them. thank you very much
-
izasrp
-
- Posts: 4
- Joined: Fri Apr 20, 2018 12:14 pm
Wed Apr 25, 2018 1:52 am
Hello,
Thank you for contacting us.
Please refer to below sample code to insert text in bookmark. Welcome to write back if there is any question.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile("Template .docx");
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(doc);
bookmarkNavigator.MoveToBookmark("Bookmark1");
bookmarkNavigator.InsertText("NewText", true);
doc.SaveToFile("Output.docx", FileFormat.Docx);
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1182
- Joined: Tue Sep 27, 2016 1:06 am
Wed Apr 25, 2018 7:21 am
Thank you so much!!!!
-
izasrp
-
- Posts: 4
- Joined: Fri Apr 20, 2018 12:14 pm
Wed Apr 25, 2018 7:26 am
Hello,
Thanks for your prompt reply.
Please feel free to contact us if you need further assistance. We will be happy to help you.
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1182
- Joined: Tue Sep 27, 2016 1:06 am
Wed Apr 25, 2018 10:37 am
Now I need to insert an image in the bookmark. How do I do that? And I could specify the height and width of the image? (Sorry for my english ;D)
-
izasrp
-
- Posts: 4
- Joined: Fri Apr 20, 2018 12:14 pm
Thu Apr 26, 2018 1:30 am
Hi,
Thanks for your contact.
Please refer to following code to achieve your requirement.
- Code: Select all
Document doc = new Document();
doc.LoadFromFile("Sample.docx");
Section section = doc.Sections[0];
Paragraph para = section.AddParagraph();
Image img = Image.FromFile("Sample.png");
//Add the picture into paragraph
DocPicture pic = para.AppendPicture(img);
//Specify width and height
pic.Height = 100.0f;
pic.Width = 100.0f;
BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(doc);
bookmarkNavigator.MoveToBookmark("Bookmark1");
//Add a paragraph with picture at the position of bookmark
bookmarkNavigator.InsertParagraph(para);
doc.SaveToFile("Result.docx", FileFormat.Docx2013);
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1182
- Joined: Tue Sep 27, 2016 1:06 am
Tue May 01, 2018 8:03 am
Hello,
Greetings from E-iceblue.
Did my code help you?
Your feedback will be greatly appreciated.
Sincerely,
Nina
E-iceblue support team
-
Nina.Tang
-
- Posts: 1182
- Joined: Tue Sep 27, 2016 1:06 am