One of the most popular downloads on the site is the “Print Clipboard” script. This AppleScript prints any text copied to the clipboard without the need to paste the text into a text editor or word processor prior to printing. One easy way to do this is to create an applescript, seems an easy thing to do but there are a couple of interesting aspects that make this worth sharing. One way to print in the background is to use the UNIX “lp ” command, there is an excellent summary of UNIX printing here. However when you copy text to the clipboard if often contains invisible non-printing characters that can cause lp to fail. So first we we convert the text to plain text and remove any application specific formatting. The as text portion grabs the stylized text from whatever other junk may be surrounding it (which can be significant), as record splits out the style and text portions, and «class ktxt» grabs the plain text portion of that. The text is then written to a file the location of which is defined within the temporary items folder. lp is then used to print the file. I was recently asked if it might be possible to have an option to save the text to a pdf file rather than printing. So I’ve added the option to print to pdf.

Copy any text to the clipboard and run the script. The first dialog shows the content of the clipboard

Click OK, and then the second dialog gives the option to Print directly (default option) or you can save as a pdf on your desktop. You can of course choose your own file name.

The AppleScript

You can download the AppleScript here.

Related Posts

One thought on “Print Clipboard

Comments are closed.