From 53844ace9a7001e7649b972a9c4ca5a1c9eb8f6f Mon Sep 17 00:00:00 2001 From: Chaim Date: Thu, 9 Apr 2026 21:38:21 +0000 Subject: [PATCH] fix: add xml:space=preserve to all w:t elements in generated DOCX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PHPWord's TemplateProcessor strips whitespace from elements that lack xml:space="preserve". Post-process the output DOCX to add this attribute, preventing words from sticking together (e.g. בהולמועדים, לקוחנחוץ). Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Tools/DirectAccessReportGenerator.php | 10 ++++++++++ manifest.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/files/custom/Espo/Modules/LegalAssistance/SmartAssistant/Tools/DirectAccessReportGenerator.php b/files/custom/Espo/Modules/LegalAssistance/SmartAssistant/Tools/DirectAccessReportGenerator.php index 2348282..81110c2 100644 --- a/files/custom/Espo/Modules/LegalAssistance/SmartAssistant/Tools/DirectAccessReportGenerator.php +++ b/files/custom/Espo/Modules/LegalAssistance/SmartAssistant/Tools/DirectAccessReportGenerator.php @@ -374,6 +374,16 @@ class DirectAccessReportGenerator } $processor->saveAs($outputPath); + + // Fix space preservation: PHPWord strips whitespace from elements + // that lack xml:space="preserve", causing words to stick together in RTL docs. + $zip = new \ZipArchive(); + if ($zip->open($outputPath) === true) { + $xml = $zip->getFromName('word/document.xml'); + $xml = preg_replace('/]*xml:space)/', 'addFromString('word/document.xml', $xml); + $zip->close(); + } } private function normalizeDate(?string $value): ?string diff --git a/manifest.json b/manifest.json index aefa634..0751235 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "LegalAssistance", - "version": "2.0.7", + "version": "2.0.8", "acceptableVersions": [">=8.0.0"], "php": [">=8.1"], "releaseDate": "2026-04-09",