From 62e4b464e4f8da8c4c8634ab8e89df7e69fa2f10 Mon Sep 17 00:00:00 2001 From: Anton Oellerer <13524304+AntonOellerer@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:53:37 +0200 Subject: [PATCH] Enforce updating of fields when opening a word document This commit sets `XWPFDocument#enforceUpdateFields` to true so that users are asked whether they want to update the references in the document on first opening it. --- .../java/com/docutools/jocument/impl/word/WordDocumentImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/docutools/jocument/impl/word/WordDocumentImpl.java b/src/main/java/com/docutools/jocument/impl/word/WordDocumentImpl.java index 3910f9a4..1c0f0366 100644 --- a/src/main/java/com/docutools/jocument/impl/word/WordDocumentImpl.java +++ b/src/main/java/com/docutools/jocument/impl/word/WordDocumentImpl.java @@ -41,6 +41,8 @@ protected Path generate() throws IOException { logger.debug("Retrieved all body elements, starting WordGenerator"); WordGenerator.apply(resolver, bodyElements, options); + document.enforceUpdateFields(); + try (OutputStream os = Files.newOutputStream(file)) { logger.info("Writing document to {}", os); document.write(os);