Copy Bookmark Contents

I have a document template that has got a bookmark.
The book mark contains a table with a few columns and there are merge fields inside each column.

I want to do this:

  1. Copy the contents of a bookmark from source document
  2. Find a book mark on the target document
  3. Replace the contents of target document bookmark with source bookmark contents.

Is this possible with Aspose Words?

Thanks.!

Hi

Thanks for your inquiry. Yes, you can achieve this using Aspose.Words.

  1. You can extract content of bookmark into a separate document. You should copy content between BookmarkStart and BookmarkEnd nodes.
  2. You can use DocumentBuilder to move to the bookmark.
  3. You can remove content from the bookmark by setting its text to empty string. Then you can use InsertDocument method to insert document with content from source bookmark at the destination bookmark.
    https://docs.aspose.com/words/java/insert-and-append-documents/

Please let me know if you need more assistance, I will be glad to help you. You can also attach sample documents and tell what bookmark you should copy and where.
Best regards.

Thanks Alexey.
can you please provide a code snippet on how to do step (3)?

I got the solution from one of your older posts.

Cannot insert node of this type at this location error

Thanks.!

It is perfect, that you already found a solution.