Skip to content

Commit

Permalink
Add instructions to get page width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
vitormattos committed Apr 15, 2023
1 parent 78cd9d4 commit 71ab23b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions doc/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -171,3 +171,21 @@ $font = reset($pdf->getFonts());
// get width
$width = $font->calculateTextWidth('Some text', $missing);
```

## Get pages width and height

Ref: [#472](https://github.com/smalot/pdfparser/issues/427#issuecomment-973416786)

```php
$parser = new \Smalot\PdfParser\Parser();
$pdf = $parser->parseFile('document.pdf');
$pages = $pdf->getPages();
$mediaBox = [];
foreach ($pages as $page) {
$details = $page->getDetails();
$mediaBox[] = [
'width' => $details['MediaBox'][2],
'height' => $details['MediaBox'][3]
];
}
```

0 comments on commit 71ab23b

Please sign in to comment.