Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Fri Apr 24, 2026 1:02 pm

Dear support team!

I have a document containing a bookmarked paragraph and a cross-reference (i.e. field) that references the bookmark.
Both the bookmarked paragraph and the field should preserve their formatting.

While the paragrapgh uses a bold font, the field should not use bold font. To achieve this, the field's format is set to "REF \* CHARFORMAT bookmark \h".

However, Spire.Doc for Java ignores the formatting of the field and uses the formatting of the bookmarked paragraph instead.
And if you open the generated document in Word and update the field using the respective Word function, the result is as expected.

Please find attached the test document file as well as the generated document file.

I use the following simple test code:
Code: Select all
        Document document = new Document();
        document.loadFromFile("Test.docx");
        BookmarksNavigator bookmarksNavigator = new BookmarksNavigator(document);
        bookmarksNavigator.moveToBookmark("bookmark");
        bookmarksNavigator.replaceBookmarkContent("This is a text", true);
        document.isUpdateFields(true);
        document.getFields().get(0).update();
        document.saveToFile("Test.generated.docx");


Any chance to fix this bug? Or is there a workaround?

Kind regards,
Marcus

mgattinger
 
Posts: 65
Joined: Fri May 21, 2021 9:03 am

Mon Apr 27, 2026 3:05 am

Hello,

Thanks for your post.
I have reproduced the issue. At present, it seems that the field “\* CHARFORMAT” setting was not recognized during updating the fields, sorry there are no other temporary solutions available. I have logged this issue into our bug tracking system with SPIREDOC-11908. Once it’s fixed, we will let you know. We apologize for the inconvenience caused.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1533
Joined: Wed Apr 25, 2018 3:20 am

Wed Jun 03, 2026 1:45 am

Hello,

Thank you for your patience.
We have released Spire.Doc for Java Version:14.6.0, which fixes issue SPIREDOC-11908. Please update and test it.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1533
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Doc