Requirements: pdfjam. Looks like some major projects depend on this? I never knew this was installed on my laptop.

Code:

pdfjam --outfile "$@" --angle 270 --fitpaper true --rotateoversize true "$@" # Clockwise
pdfjam --outfile "$@" --angle 90 --fitpaper true --rotateoversize true "$@" # Anti-clockwise

Note: For some reason, rotating the document and reverting it (or doing it 4 times) gets you a different hash.

Bonus: Add this to Yazi config for this:

Rotate options in Yazi

[[open.rules]]
url = "*.pdf"
use = ["pdf"]

# ...

[[opener.pdf]]
desc = "Rotate Clockwise"
orphan = true
run = "pdfjam --outfile \"$@\" --angle 270 --fitpaper true --rotateoversize true \"$@\""

[[opener.pdf]]
desc = "Rotate Anticlockwise"
orphan = true
run = "pdfjam --outfile \"$@\" --angle 90 --fitpaper true --rotateoversize true \"$@\""