We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Bookmark text not replaced

Hi,

we are trying to replace the text of a bookmark in a Word document using Aspose.Words.DLL for .NET version 19.10. Instead of replacing the whole bookmark text, the replacement text appears next to the existing bookmark text.

The code is as follows:

  var wordDoc = new Aspose.Words.Document(@"before.docx");

  var bookmark = wordDoc.Range.Bookmarks[1];
  bookmark.Text = "edited bookmark text";

  var saveFormat = Aspose.Words.SaveFormat.Docx;
  var outStream = new MemoryStream();
  wordDoc.Save(outStream, saveFormat);
  File.WriteAllBytes(@"after.docx", outStream.ToArray());

Please find attached files before.docx and after.docx in the attached ZIP file to demonstrate this behaviour. bookmark-text.zip (31.1 KB)

The expected result would be that the whole bookmark text wold be replaced with our custom text. Unfortunately, we can’t remove the bookmark after filling it to get rid of the previous text, because it may need to be filled with a different value later on. Please take a look at this behaviour and let us know if and when it can be fixed.

@Eva_M

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19583. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-19583) have been fixed in this Aspose.Words for .NET 19.12 update and this Aspose.Words for Java 19.12 update.