Different types of pdf rotations treated differently

Which product are you using?

PDF.js Express Version
8.7.4

Detailed description of issue
We are using a viewer with custom rectangular drawing tool to allow users to select regions in pdfs and later on we use tabula-java lib to extract tables from these regions.
The issue appears to be the rotations of pdfs. Some pdfs are exported from various tools e.g. CAD tools in a landscape position and pdf.js express detects document rotation to be 90deg (BUT NOT FOR ALL LANDSCAPE PDFs, only some). The other pdfs were created with no rotation, but later on in some viewer rotated and saved. Again pdf.js express detects them as rotated. This all would be fine, because on the viewer side I manage to handle these rotations with no issue and adjust the selection tool.
The problem is that when I send the end coordinates to tabula-java, that lib treats some pdfs that in the viewer have document rotation as without rotation. How could this be happening? Isn’t document rotation internal pdf property same everywhere? Is it possible to distinguish these rotations? Any insights/suggestions on how to come across issue of same pdfs having different rotations depending on the lib parsing it?

Expected behaviour
document rotation same everywhere or method to get different types of pdf rotations.

Does your issue happen with every document, or just one?
various pdfs

Link to document
not available

Code snippet
N/A

Hello virginija,

There are two types of rotation that can be applied, internal and viewer.

Internal rotation is when the rotated page is saved into the PDFs metadata, explicitly telling the viewer that a page is rotated.

Viewer rotation is when a page has been rotated in the viewer, essentially a “temporary” rotation that isnt added to the metadata until downloaded.

If you can provide some sample files, I can highlight how to tell the difference.

Best regards,
Tyler