pdf-tools icon indicating copy to clipboard operation
pdf-tools copied to clipboard

Allow for rotation of displayed pages

Open SterlingHooten opened this issue 2 years ago • 3 comments

Is there a way to rotate pages in the displayed buffer without mutating the original file?

This was called for twice in the previous repo with a suggestion for a solution at https://github.com/politza/pdf-tools/issues/89#issuecomment-657043167 but the request appears to have been closed in a bulk operation when moving to this repo.

This would be very useful, and is a feature in almost any other pdf viewer.

SterlingHooten avatar Sep 21 '22 10:09 SterlingHooten

You can bind image-rotate in pdf-view-mode-map. I have it bound to R.

9viz avatar Sep 22 '22 11:09 9viz

Yes, this works well for viewing. However, as soon as you do things like trying to add annotations, the image is reverted to its original orientation. An alternative for people that want to or are okay with modifying the original file is to use my qpdf wrapper qpdf.el. Then calling the command qpdf and pressing m brings up some modification options, including page rotation.

orgtre avatar Sep 22 '22 11:09 orgtre

Maybe we should keep an association list for the metadata of rotations.

tongjie-chen avatar Sep 23 '22 21:09 tongjie-chen

You can bind image-rotate in pdf-view-mode-map. I have it bound to R.

This seemed to be working well but I think it's incompatible when the view has been sliced to a different region. With the default bounding box the rotation works as expected, but after using =(pdf-view-set-slice-using-mouse)= rotation gives the error: "No image under point". I'm not familiar enough with the internals of pdf-tools to know how these are being rendered differently.

Perhaps a hack would be to detect if there was a slice in effect, store the slice data, remove the slice, transform (rotate) the slice box, rotate the image, and then re-apply the slice.

SterlingHooten avatar Oct 24 '22 17:10 SterlingHooten

24 Oct 2022, 22:53 by @.***:

You can bind image-rotate in pdf-view-mode-map. I have it bound to R.

This worked for some pdfs, but I just ran into another type (not sure how to classify these) which gives the error "No image under point". I'm not familiar enough with the internals of pdf-tools to know how these are being rendered differently.

Can you try out my linked PR in this issue?Message ID: @.***>

9viz avatar Oct 24 '22 20:10 9viz

I've merged @vizs 's PR #165 , which adds a convenient key-binding and functionality for rotation. Please try out the change in the latest pdf-tools.

vedang avatar Jan 17 '23 03:01 vedang