Posts Tagged Mac

Working with PDFs in OS X

I've just been playing around creating some eps files with gnuplot, and have subsequently had to convert them to PDFs for someone else to view. Turns out I wasn't aware of the following:

1) You can drag-and-drop pages within PDFs in Preview.app, to re-arrange the page order. You can also delete pages using the Edit menu (and add blank ones, if that floats your boat). More detail here.

Editing a PDF in Preview.app

Editing a PDF in Preview.app

I've also just discovered that you can use Cmd-R to rotate either a single page or all pages between portrait and landscape orientation.

2) If you're a fan of the command-line, there's a built-in script to join multiple PDFs. I originally found it on this blog (turns out they're investigating protein misfolding and aggregation, small world). Basically, you can find the script at the following location (all one line, obviously):

/System/Library/Automator/Combine PDF pages.action/Contents/Resources/join.py

If you want to add the path to your .profile file, don't forget to put it in quotes otherwise OS X will baulk at the spaces. To use the script, just go like so…

~ $ join.py -o output.pdf input1.pdf input2.pdf … inputN.pdf

I'm not suggesting these are particularly life-changing pieces of news, but I wasn't aware of them so thought I'd spread the love.

Tags: , , ,

Toggle Bluetooth with Applescript

I've just written a little Applescript to toggle the Bluetooth power on my MacBook on or off. It doesn't take any parameters or anything, it literally just toggles it off if it's already on, or on if it's already off. The script looks like this:

#! /usr/bin/osascript
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# *  Author:	Haydn Williams
# *  URL:	http://www.haydnwilliams.com
# *  Date:	March 2008
# *  Script:	toggleBluetooth.scpt
# *  Purpose:	Toggle bluetooth status
# *  Useage:	toggleBluetooth.scpt
#  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preferences.Bluetooth"
	try
		tell application "System Events"
			tell process "System Preferences"
				click checkbox "On" of window "Bluetooth"
			end tell
		end tell
	on error
		display dialog "Failed to toggle bluetooth."
	end try
	tell application "System Preferences" to close the first window
end tell


You can download the compiled script fromĀ here. Please note that you'll need to 'Enable GUI Scripting' in the AppleScript Utility (you can find it in the AppleScript folder of Applications). To run the script, just double-click on it. Please note that this will probably only work on English language systems, but should be easy enough to alter.

Tags: , , , ,