-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
Is it there any way to get the orientation (portrait or landscape) from a Media object?
We call Fileupload.get() and we would like to know the orientation of this Media object.
Thank you,
Javier
Hey there,
In that case, you would need to use a dedicated PDF library, such iText, openPDF or other similiar "service side PDF handling library".
I expect that most PDF libraries would have the ability to give you the document format, or failing that, the page width and page height for you to compare.
Just a warning there: while most user will generate PDFs using a standard print paper format (usually A4), there is no spec in PDF that says they have to use a standard format.
You could create a 1px by 1px pdf containing a black dot, and it would be a valid PDF file. That's probably an edge case, but you should be aware of that in advance :D
Hi there,
The media you receive at the end of fileupload is just a wrapper for the byte content of the upload, with a few meta-data provided by the browser upload (name, size, extension, etc).
The orientation is not part of that metadata. It's also only applicable to a few file types.
If you need that information, you may need to read the file content at server-side, and retrieve the orientation from the file content itself.
What type files do you want to retrieve the orientation for? (image, pdf, word, etc?)
Asked: 2022-05-31 00:27:16 +0800
Seen: 14 times
Last updated: Jun 15 '22