Skip to content

Commit

Permalink
fix: Return page with and height from document
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
vitormattos committed Apr 5, 2024
1 parent fb77eab commit bf8a9af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions doc/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit bf8a9af

Please sign in to comment.