How to Print the Selected Text?

Hello,

Would anyone know of way to print the selected text?

Thank you.

Do you mean Print PDF to Desktop etc. and this should work in any app @ronald?

1 Like

Thank you.

No I mean:

Wherever you are, document, web page, etc, just highlight text and run macro to print.

Does ⌘P not work for you?

1 Like

I have a found a “Print clipboard” script. Out of the box it doesn’t work for me, but maybe that’s because I have no printer here.

1 Like

I can offer you this in the video @ronald.

Thank you for your answer.
In OSX Cmd-P does not offer ‘selection’ as an option

Without having found the right solution, I think it should be something like this.

You make a selection and trigger the macro.

The macro does this:

  1. Copy the selection.
  2. Converts the selection to PDF/RTF somehow.
  3. The PDF/RTF file is sent to printer.
1 Like

Yeah, that’s what the AppleScript basically does.

@ronald, have you tried the AppleScript? On my machine it successfully sends a print job to the printer queue, which means that it would probably work — if I had a printer connected.

PS:

You can launch the script with a macro like this:

  1. In the macro set the correct path to the AppleScript
  2. Make a selection for example in Safari
  3. Launch macro

_[test] Print Selection.kmmacros (1.7 KB)

1 Like

Missed the AppleScript in the thread. It works but only for text.
No images or formatting.

I have hacked together this from different AppleScripts, which uses TextEdit to print.
I am sure it can be improved. :slight_smile:

Keyboard Maestro “Print selection” Macro

Print selection.kmmacros (2.5 KB)

2 Likes

Seems to work nicely :slightly_smiling_face:

1 Like

@Tom @JimmyHartington
Thanks very much Jimmy and Tom!

I downloaded the macro and tried it. I highlight the text and graphics I wish to print and trigger the macro yielding “No RTF in clipboard”. So I tried highlighting and copying to the clipboard before triggering. Same result.

Any ideas?

Thx.
Bruce

1 Like

I forgot to say I was using Firefox. Trying it in Safari, these is no error message but no print action either.

Bruce

1 Like

Here it works fine with Safari.

Apparently Firefox doesn’t put any RTF to the clipboard, so the message “No RTF in clipboard” was correct.

Here is a very slightly modified version of @JimmyHartington’s script:

Print Selection as RTF or Plain Text.kmmacros (2.4 KB)

If it doesn’t find RTF it will print Plain Text instead. This won’t be very useful for Firefox, but maybe for other apps that don’t output RTF.

For example, this way you can also print a Finder selection as a list of files.

2 Likes

Hi Tom

Nice change.
As I wrote. My script was stitched together from 2 sources and I am by no means an AppleScript expert.

So thanks for improving this macro.

1 Like

I have twisted the AppleScript to make it work with pictures/screenshots in the System Clipboard as well.

tell application "TextEdit"
	activate
	make new document at the front
	tell application "System Events" to keystroke "v" using command down
	print front document without print dialog
	delay 1 --added a delay to watch the process
	close front document without saving
end tell