-
Notifications
You must be signed in to change notification settings - Fork 544
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 <[email protected]>
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 |
Follow up of issue smalot#427 using the suggested code at issue smalot#472. Notes: Have PDF files that the pdfparser can't get the MediaBox, as fallback to get the page dimension is possible to use the BBox (Bounding Box). The Bounding Box could not have the real dimension of a page put is a solution to have a value that could be the page dimension at cases that isn't possible to found the MediaBox. Signed-off-by: Vitor Mattos <[email protected]>
Follow up of issue smalot#427 using the suggested code at issue smalot#472. Notes: Have PDF files that the pdfparser can't get the MediaBox, as fallback to get the page dimension is possible to use the BBox (Bounding Box). The Bounding Box could not have the real dimension of a page put is a solution to have a value that could be the page dimension at cases that isn't possible to found the MediaBox. Signed-off-by: Vitor Mattos <[email protected]>
Follow up of issue smalot#427 using the suggested code at issue smalot#472. Notes: Have PDF files that the pdfparser can't get the MediaBox, as fallback to get the page dimension is possible to use the BBox (Bounding Box). The Bounding Box could not have the real dimension of a page put is a solution to have a value that could be the page dimension at cases that isn't possible to found the MediaBox. The BBox only was found at the first page, maybe would be good to check if have a best way to get the page dimensions only using the MediaBox and solving the issue that hide this information. Signed-off-by: Vitor Mattos <[email protected]>
Hello,
How to get the PDF width and height ?
Thanks
Vincent
The text was updated successfully, but these errors were encountered: