From ce8b68900dc3fd2b4e55dbd79f0fd5cfba1df561 Mon Sep 17 00:00:00 2001 From: stumpylog <797416+stumpylog@users.noreply.github.com> Date: Tue, 21 Jul 2026 08:05:51 -0700 Subject: [PATCH] Fix: preserve document fields during Gotenberg conversion Gotenberg's LibreOffice route enables updateIndexes by default, which refreshes dynamic fields (e.g. auto-dates) to the current date. Disable it so field values are preserved as authored. --- src/paperless/parsers/tika.py | 5 +++++ src/paperless/tests/parsers/test_tika_parser.py | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/paperless/parsers/tika.py b/src/paperless/parsers/tika.py index 674d74fe2..07af9db72 100644 --- a/src/paperless/parsers/tika.py +++ b/src/paperless/parsers/tika.py @@ -423,6 +423,11 @@ class TikaDocumentParser: logger.info("Converting %s to PDF as %s", document_path, pdf_path) with self._gotenberg_client.libre_office.to_pdf() as route: + # Preserve document fields as authored. updateIndexes (Gotenberg's + # default) triggers a refresh() that rewrites dynamic fields like + # auto-dates to the current date. + route.update_indexes(update_indexes=False) + # Set the output format of the resulting PDF. # OutputTypeConfig reads the database-stored ApplicationConfiguration # first, then falls back to the PAPERLESS_OCR_OUTPUT_TYPE env var. diff --git a/src/paperless/tests/parsers/test_tika_parser.py b/src/paperless/tests/parsers/test_tika_parser.py index 560527934..50ee75ae0 100644 --- a/src/paperless/tests/parsers/test_tika_parser.py +++ b/src/paperless/tests/parsers/test_tika_parser.py @@ -223,4 +223,11 @@ class TestTikaParser: assert form_field_found + # Field updates must be disabled so LibreOffice preserves document + # fields (e.g. auto-date fields) as authored rather than refreshing + # them to the current date. + assert any( + b'name="updateIndexes"' in part and b"false" in part for part in parts + ) + httpx_mock.reset()