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