vedang / pdf-tools

Emacs support library for PDF files.
https://pdftools.wiki
GNU General Public License v3.0
641 stars 90 forks source link

Allow for rotation of displayed pages #152

Closed SterlingHooten closed 1 year ago

SterlingHooten commented 2 years ago

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.

9viz commented 2 years ago

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

orgtre commented 2 years ago

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.

tongjie-chen commented 2 years ago

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

SterlingHooten commented 2 years ago

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.

9viz commented 2 years ago

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: @.***>

vedang commented 1 year ago

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.