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. Image for the cookie policy date
close icon

Docio - Removing blank line

Good day,

I am attempting to create a small app that will push data from an entry form into bookmarks in a word doc. However, when a field is left blank, and therefore a bookmark is left blank, I would like to have the line that the bookmark is in be removed if there is no other text in the line.

So, if the page looked like this:

Line 1
[Bookmark]
Line2 

If [Bookmark] is blank and since there is no other text in that line, I want it to appear like this:

Line 1
Line2

Right now, if the bookmark is left blank it appears with a blank row like this:

Line 1

Line 2

Is it possible to identify the row that the bookmark is in and determine that no text exists in the row and then delete that row?

Thanks!

1 Reply

SB Suriya Balamurugan Syncfusion Team January 7, 2020 04:38 PM UTC

Hi Travis,

Thank you for contacting Syncfusion support.

It is feasible to identify the replaced bookmark content contains text or not and remove that bookmark paragraph from the Word document.

We have prepared a sample application to remove the blank paragraph after replacing the bookmark content in the Word document as per your requirement and it can be downloaded from the below link:

https://www.syncfusion.com/downloads/support/forum/150418/ze/CreateWordSample-1598079975

Note: Please find the template Word document in the “Data” folder of above sample.

We have done the following things in the sample:
  1. Loads a template Word document.
  2. Moves to the location before the end of the specified bookmark in the document.
  3. Replaces the bookmark content with empty string (Here you can replace the bookmark content with data from an entry form).
  4. Gets the paragraph contains the specified bookmark.
  5. Removes that paragraph when it doesn’t contain text.
  6. Saves the Word document.

Please let us know if you have any other questions.

Regards,
Suriya Balamurugan.
 


Loader.
Live Chat Icon For mobile
Up arrow icon