From a60ba4adc122f7ee9ad478cc5c48d55146bd3e8c Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Fri, 5 Apr 2024 17:33:33 -0300 Subject: [PATCH] fix: make compatible with FPDF I identified an edge case parsing a PDF generated with FPDF. The MediaBox don't exists at page scope and was necessary to get from document scope. Signed-off-by: Vitor Mattos --- lib/Service/PdfParserService.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/Service/PdfParserService.php b/lib/Service/PdfParserService.php index d57559fc13..6c80644565 100644 --- a/lib/Service/PdfParserService.php +++ b/lib/Service/PdfParserService.php @@ -72,6 +72,9 @@ private function parsePdfOnlyWithPhp(string $filename): array { ]; foreach ($pages as $page) { $details = $page->getDetails(); + if (!isset($details['MediaBox'])) { + $details = reset($pdf->getObjectsByType('Pages'))->getHeader()->getDetails(); + } $output['d'][] = [ 'w' => $details['MediaBox'][2], 'h' => $details['MediaBox'][3]