Syncfusion DocIO — how to insert image (local file) at bookmark using BookmarksNavigator

syncfusion

I have been using Syncfusion DocIO for generating MS Word documents from my .net applications (winforms). So far I have dealt with plain text and it is fairly straightforward to insert text in a word document template where bookmarks serve as reference points for text insertion.

I am navigating the bookmarks using BookmarksNavigator.MoveToBookmark() . Now I need to insert an image at a bookmark but I am at a loss at how to go about it.

Please help…

Thanks.

Best Solution

Specifically for adding it to a bookmark :

            //Move to the specified bookmark
            bk.MoveToBookmark(bookmark);

            //Insert the picture into the specified bookmark location
            bk.DeleteBookmarkContent(true);

            // we assume the text is a full pathname for an image file
            // get the image file
            System.Drawing.Image image = System.Drawing.Image.FromFile(sText);

            IWParagraph paragraph = new WParagraph(document);
            paragraph.AppendPicture(image);
            bk.InsertParagraph(paragraph);
Related Question