From bf8a9afb8ef9da0ee2639b821acdbf1aa0380725 Mon Sep 17 00:00:00 2001 From: Vitor Mattos Date: Fri, 5 Apr 2024 15:12:03 -0300 Subject: [PATCH] fix: Return page with and height from document Some documents could have pages without MediaBox, at this case we need to get the MediaBox from document and not from a specific page. Signed-off-by: Vitor Mattos --- doc/Usage.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/Usage.md b/doc/Usage.md index 398c243c..0abbbf00 100644 --- a/doc/Usage.md +++ b/doc/Usage.md @@ -224,6 +224,10 @@ $pages = $pdf->getPages(); $mediaBox = []; foreach ($pages as $page) { $details = $page->getDetails(); + // The page could haven't the Mediabox, then we get this information from document + if (!isset($details['MediaBox'])) { + $details = reset($pdf->getObjectsByType('Pages'))->getHeader()->getDetails(); + } $mediaBox[] = [ 'width' => $details['MediaBox'][2], 'height' => $details['MediaBox'][3]