From ed2679ec3ea391889cfe7ab4d4d122dd131272d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Fromme?= Date: Tue, 18 Mar 2025 20:09:50 +0100 Subject: [PATCH] fix: ensure pdf annotations are preserved when sanitizing upload --- src/Service/Pdf/Sanitizer.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Service/Pdf/Sanitizer.php b/src/Service/Pdf/Sanitizer.php index fd29ee0..4915c40 100644 --- a/src/Service/Pdf/Sanitizer.php +++ b/src/Service/Pdf/Sanitizer.php @@ -22,7 +22,9 @@ class Sanitizer $filesystem = new Filesystem(); if (true === $backup) { - $filesystem->copy($inputFilepath, $inputFilepath.'.bak'); + $parts = pathinfo($inputFilepath); + $backupFilename = sprintf('%s/%s.orig.%s', $parts['dirname'], $parts['filename'], $parts['extension']); + $filesystem->copy($inputFilepath, $backupFilename); } $tempFilename = sha1($inputFilepath); @@ -57,6 +59,7 @@ class Sanitizer '-dNOPAUSE', '-dQUIET', '-dBATCH', + '-dPreserveAnnots=false', '-sDEVICE=pdfwrite', '-dCompatibilityLevel=1.4', '-sOutputFile='.$outputFilepath,