From ce07a05e41ca203d778a91976784590bde555ebc Mon Sep 17 00:00:00 2001 From: wurst-hans <56444979+wurst-hans@users.noreply.github.com> Date: Fri, 10 Jan 2025 17:31:05 +0100 Subject: [PATCH] Fixed incompatible PDF/A header bytes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When using rand(128, 256), the value 256 can be randomly generated, which results in the hex value “00”. However, this is not compliant with PDF/A-3. --- src/ZugferdPdfWriter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZugferdPdfWriter.php b/src/ZugferdPdfWriter.php index 5c0c0531..d6fa3250 100644 --- a/src/ZugferdPdfWriter.php +++ b/src/ZugferdPdfWriter.php @@ -102,7 +102,7 @@ public function setPdfVersion($version = '1.3', $binary_data = false): void if ($this->deterministicModeEnabled === true) { $this->PDFVersion .= "\n" . '%' . chr(128) . chr(129) . chr(130) . chr(131); } else { - $this->PDFVersion .= "\n" . '%' . chr(rand(128, 256)) . chr(rand(128, 256)) . chr(rand(128, 256)) . chr(rand(128, 256)); + $this->PDFVersion .= "\n" . '%' . chr(rand(128, 255)) . chr(rand(128, 255)) . chr(rand(128, 255)) . chr(rand(128, 255)); } } }