-
Notifications
You must be signed in to change notification settings - Fork 539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to get the PDF width and height ? #427
Comments
Hello all, i need the same information. Is there already news about this. Thank you and greetings |
Not to my knowledge, sorry. |
Hi, I hope this is still of some use. Actually I have a look, because of issue #472. You can use MediaBox info for this. If you look The PDF Specification, on page 77 the MediaBox is defined as:
There is a lot of info in the specification and I am not an expert on this. For getting that info:
Media box should be something like:
Hope this can help! |
Hi! Im trying to get pdf page height and width using the code in your example, but I only get the following properties: But, if I print the whole pdf object, I can search "MediaBox" and I see two values that appear to be Height and Width. I copied the result in a pastebin for the sake of the readers :) Any advice on how to get this working? Thanks a lot in advance! |
Same question. Any idea how to get width and height from fpdf generated file? |
The same of previous suggestion but with more details: $pages = $pdf->getPages();
$mediaBox = [];
foreach ($pages as $page) {
$details = $page->getDetails();
$mediaBox[] = [
'width' => $details['MediaBox'][2],
'height' => $details['MediaBox'][3]
];
} Output:
|
* Add instructions to get page width and height Based on #427 (comment) * Update doc/Usage.md * Replaced tabs with whitespaces --------- Co-authored-by: Konrad Abicht <hi@inspirito.de>
Only to register here the information, 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: I added this information here in the documentation here: #700 |
Hello,
How to get the PDF width and height ?
Thanks
Vincent
The text was updated successfully, but these errors were encountered: