Rotate Text in Preview App

I have a Keyboard Maestro macro the allows me to add a "date paid text" onto a PDF receipt opened in Preview.

It makes a kind of stamp, like this:
Pasted%20Graphic%202

I would like to have it at an angle, like this:
Pasted%20Graphic%201

So, on the MacBook it is possible to select and rotate the text by using two fingers on the trackpad. But I can't find anyway to do this on my iMac (which uses a mouse rather than a trackpad). There doesn't seem to be any keyboard or menu shortcut to rotate text in Preview. And yet... the text can be rotated using a trackpad, which means Preview has some command to rotate text.

Does anyone know of a method to get Preview to angle text without the use of a trackpad? And if it could be incorporated into a Keyboard Maestro macro?

Thanks for any help or suggestions in advance

Here is my existing macro, (without the rotation)
27
Paid.kmmacros (4.7 KB)

Im having trouble rotating text with my track pad, how did you do it?

Im having trouble rotating text with my track pad, how did you do it?<<

You need to enable "rotation" as one of the gestures for the trackpad in Settings on the MacBook - then touching with two fingers and twisting will rotate things (not just for Preview but for other apps too). It seems to be disabled by default (maybe because it could be annoying to accidentally rotate things!).

Thanks, unfortunately i am stuck trying to figure out to do it using maestro just like you......

There does not appear to be any way to rotate the text in Preview except via the trackpad.

From the documentation:

Rotate a shape: Select the shape and place the pointer over it, place your thumb and a finger on the trackpad, then pivot them around each other as if you’re turning a jar lid. You can even Shift-click to select multiple shapes and rotate them together.

I have reported this as a bug.

One option would be to create the image in Keyboard Maestro, and rotate it and then place that.

But unfortunately there is no way to paste an image on to a PDF in Preview. Sigh.

Thank you for looking into this Peter. Yes, it is very frustrating that Preview has the ability to rotate text but only via a trackpad. I wonder if someone knows how to trick Preview into thinking an input is coming via a trackpad? Or better still, Apple just add the ability to rotate, no matter what the input device is.

One tiny thing that has come out of this thread and your example macro is, I realise my initial macro had many more steps than it needed. Looking at your Macro, I have now reduced my macro down to just two steps. Here it is again, in case anyone finds it useful.54 Paid.kmmacros (2.8 KB)
And one other little bit of info - in the Keyboard/Text Settings of System Preferences I like to uncheck "Use smart quotes and dashes" otherwise typed dashes get converted into longer dashes. It took me ages to find out this was what was happening when I typed a few dashes and my dashes got messed up.

It seems to be a rule of life that anything labelled "smart" whether on a computer or TV should always be disabled.

Interestingly, I now remember why I split my original macro up into sections with pauses in between each line of typed text.

If all the text is in one Insert Text Action, the typing sometimes trips over itself and mixes elements from the three lines of text.
46

By splitting the inserted text over three Insert Text Actions and putting a tiny pause between these Actions (0.01 seconds) the typing of the three lines is always correct (and not mixed up).
20

Paid.kmmacros (23.9 KB)

1 Like

Not using Preview.app, but this AppleScript from AppleScript: Image Events seems to work fine:

set this_file to choose file
try
 tell application "Image Events"
 -- start the Image Events application
 launch
 -- open the image file
 set this_image to open this_file
 -- perform action
 rotate this_image to angle 270
 -- save the changes
 save this_image with icon
 -- purge the open image data
 close this_image
 end tell
on error error_message
 display dialog error_message
end try

That rotates just the image right? Keyboard Maestro can do that natively. But unfortunately there does not appear to be any way to paste the image in in Preview. You can insert text, but then you can't rotate it (except with a track pad), or you can create an image and rotate it, but then you can’t insert it in to the PDF.

Being a receipt that presumably is being returned to a customer who wouldn't (and shouldn't) have cause to require a PDF document compose of individual elements, would it be worth considering converting the PDF contents (even just for a single page requiring the stamp) into an image, applying the rotated image of the stamp on top of that, then converting that back into a PDF ?

In my case, the PDF is just for myself so I know which bills I have paid and I'd rather keep it as a PDF with original text elements that can be searched etc. As I can rotate the "stamp" using the trackpad on my MacBook trackpad I can achieve what I want in the end. I was really just curious if there was any way of doing this without a trackpad when I am working on my iMac.

As others have pointed out elsewhere it is possible to rotate text to 90º vertical in Preview by first rotating the whole page in Preview, then adding the text (which will be horizontal) and then rotating the whole page back to its original orientation. The text will now be vertical. But there is no way to do this (without a trackpad) if you say wanted the text at 45º.

It would be nice if the next version of Preview would allow text to be rotated using the mouse or by typing in an amount (but I can't see this being very high up on the list of things for Apple to do).

Interesting, I didn't know this technique, which means there might be a way to do it programmatically using the same technique but with a custom angle. There are some objective-c classes that allow PDF document/page rotation, but I'd have to experiment at some point and find out what they actually do.

1 Like