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

Free Support Forum - aspose.com

Issue with bookmark in Word

We have updated from an old version of Aspose.Words (14.6) to a newer one (21.5).
We use Aspose.Words to convert Docx files to PDF. One issue we have seen is that bookmarks are now sometimes losing text.
We have figured out that there must be some kind of implicit “UpdateFields” happening now, that didn’t in 14.6.before update (output 14.6).png (675 Bytes)
after update (21.5).png (891 Bytes)
Could someone confirm that this is how it should work? Is this something we can turn off?

(just fyi if I select the bookmark in question and update it inside Word, we get the same result as Aspose 21.5.

Many thanks

@a95johjo Aspose.Words always tries to mimic MS Word behavior. But could you please attach your document here for testing? We will check the issue and provide you more information.

Hi Alexey, thanks for the reply. Word (v.2016) removes the “10” but only after I have forced a field update. Does Aspose always do a field refresh before saving to PDF, and is this changed since 14.6?
I had the impression we would have to actively call doc.UpdateFields() to get this behavior.
The file is not mine but my customers’ so I prefer not to share it.

it should also be noted, that trying to Isolate the issue by removing all other text, does not reproduce the issue. So what I think happens is that the bookmark points to an invalid reference or something like that. So this file does not show the error. Isolated issue.docx (65.6 KB)

here is a file with isolated problem. I was able to generate this issue by editing the text shown for the bookmark.Isolated issue.docx (65.4 KB)

@a95johjo You have encountered the desired behavior. If take a look in the document xml, you can notice the following:

      <w:bookmarkStart w:id="0" w:name="_Ref493608490"/>
      <w:r w:rsidRPr="00B268AA">
        <w:t xml:space="preserve">Table </w:t>
      <w:bookmarkEnd w:id="0"/>
      <w:r w:rsidR="00EF036C">
      <w:r w:rsidRPr="00B268AA">
        <w:t xml:space="preserve">: </w:t>

as you can see the bookmarked text is Table , Aspose.Words automatically updates all fields upon saving document to fixed page formats and ref field is updated to the appropriate bookmarked text. This is correct behavior.
However, you can disable updating some of fields to keep old value in field result. For example you can use the following code to disable updating REF fields in your document:

Document doc = new Document("C:\\Temp\\in.docx");

foreach (Field field in doc.Range.Fields)
    if (field.Start.FieldType == FieldType.FieldRef)
        field.IsLocked = true;


Thanks Alexey for confirming. It does not behave like this in 14.6, hence my question.
But then we know. It becomes a bit of a difference since when we present the PDF on screen, people wonder why it doesn’t look the same as in Word, but of course, saving to PDF will execute any events that should happen on Save.

@a95johjo Please feel free to ask if you have any other issues. We will be glad to help you.