PDF Coordinate Systems, Rotation Matrices & Page Dictionaries: A Technical Guide
When scanning physical multi-page documents through automatic document feeders (ADF), sheets frequently enter rotated sideways or upside down. While some desktop PDF readers offer a "View > Rotate" menu option, this only changes the temporary on-screen viewport orientation. Once the file is emailed or opened in a web browser, it reverts to its crooked orientation.
How the PDF /Rotate Entry Operates in ISO 32000
In the official PDF specification, every page object dictionary contains an optional /Rotate entry that defines the number of degrees by which the page should be rotated clockwise when displayed or printed:
- Permitted Integer Multiples: The value must be an integer multiple of 90 degrees (
0,90,180, or270). - Inheritance Rules: If a leaf
/Pagenode does not explicitly define a/Rotateentry, it inherits the attribute from its parent node in the page tree. - Transformation Matrix Interaction: When a viewer renders a rotated page, it multiplies the Default User Space matrix with an affine rotation matrix: \[ \begin{bmatrix} \cos(90^\circ) & \sin(90^\circ) \\ -\sin(90^\circ) & \cos(90^\circ) \end{bmatrix} = \begin{bmatrix} 0 & 1 \\ -1 & 0 \end{bmatrix} \]
RKPDF updates the dictionary /Rotate tag directly in the PDF binary without touching the page content stream. This means your text remains searchable and vector lines stay razor sharp.