Delete Bookmarks with no data

Hi

I am trying to use SyncFusion to populate bookmarks then remove the rows where Bookmarks have not been created. This is for a list of items that can be anthing from 1 to 30 long. I found your code used to populate Bookmarks, which I use but cannot find a way to delete rows where Bookmarks have not been populated. I have populated only 2 bookmarks but will have to do up to 30 then delete all rows where there is no data

        protected void Button1_Click(object sender, EventArgs e)

        {

            //Opens the Word template document

            using (WordDocument document = new WordDocument(ResolveApplicationDataPath("/") + "/Letter Formatting.docx"))

            {

                //-------------------Bookmarks-----------------------------

                //Creates the bookmark navigator instance to access the bookmark

                BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);

                //Moves the virtual cursor to the location before the end of the bookmark "Northwind"

                bookmarkNavigator.MoveToBookmark("Bookmark1");

                //Inserts a new text before the bookmark end of the bookmark

                bookmarkNavigator.InsertText("Condition1");


                //Creates the bookmark navigator instance to access the bookmark

                BookmarksNavigator bookmarkNavigator = new BookmarksNavigator(document);

                //Moves the virtual cursor to the location before the end of the bookmark "Northwind"

                bookmarkNavigator.MoveToBookmark("Bookmark2");

                //Inserts a new text before the bookmark end of the bookmark

              bookmarkNavigator.InsertText("Condition2");


                //----------------------------------------------------------




                //Saves the Word document to disk in DOCX format

                document.Save("Result.docx", FormatType.Docx, HttpContext.Current.Response, HttpContentDisposition.Attachment);

            }

        }


        //Get the path for Word template document

        protected string ResolveApplicationDataPath(string fileName)

        {

            //Data folder path is resolved from requested page physical path.

            string dataPath = new System.IO.DirectoryInfo(Request.PhysicalPath + "..\\..\\Test\\").FullName;

            return string.Format("{0}\\{1}", dataPath, fileName);

        }


1 Reply

AN Anto Nihil Sahaya Raj Syncfusion Team April 7, 2022 03:55 PM UTC

Hi Murray,

From the given details, we have suspect that your requirement is to remove the bookmarks present in the Word document.

To achieve your requirement, please refer to the below UG documentation link

https://help.syncfusion.com/file-formats/docio/working-with-bookmarks#removing-a-bookmark-from-word-document

If we misunderstood any of your requirements means, please share with us the complete details about your end requirement. Also, kindly share with us the input and the expected output document/screenshot. Thereby, we will check the feasibilities to meet your requirement and will provide you with the appropriate solution

Regards,

Anto Nihil S


Loader.
Up arrow icon