The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniFocus > OmniFocus Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Omni Focus Perspective Print to Dropbox Thread Tools Search this Thread Display Modes
Hello All,

I got this idea from a member of the forums since I was in a dilema, I love OmniFocus but needed a nice way to keep track of it on my Android Phone (mini Tablet / Samsung Galaxy Note 2).

I was having a hard time with this, and then whpalmer4 just told me to use perspectives. Unfortunately I was using them on my Mac and my iPad but never used them to print things out so when I was doing a regular print was disappointed.

Having played with perspectives I was able to accomplish what I wanted, but hated the manual print options, or the automater. So I created this applescript to automate the selection of various perspectives and printing of them to a Dropbox folder.

Requirements for this script:
1. Your Dropbox folder must be in /Users/username/Dropbox
2. You want to create a Folder there called OmniFocus
3. You need to modify the applescript and change the perspective names you use in variable "theListPerspectives"

The Perspective List goes in quotes and is separated by a comma.
(example: "List1", "List2", etc) - In the scripts are some of the ideas for the perspectives that I have but you either name your perspective like mine or change the names.

It does not matter how many perspectives you have, the script will print them all.

Please be aware, that I have to delete the PDF files in the OmniFocus directory before creating a new one.
 
Version 1.0 of the script

Code:
-- OmniFocus Perspective Print to Dropbox
-- Written by Yury German <yury (at) technologysecure.com>
-- Version: 1.00
-- Date of Change: 2013-01-03
-- 
-- About this script:
-- This takes a number of perspectives taht are defined in the List below and creates
-- a PDF export for each of them to a Dropbox folder for viewing on other devices
-- You can do this manually, but this does it fast and all at once, so no matter what views/perspectives
-- 
-- Credit:
-- Credit for the idea behind the script goes to whpalmer4 on omni Forums.
-- I was complaining about the PDF view looked bad, and it was because I was not using perspectives
-- So now I created this script do do this.
set userName to short user name of (system info)
set pdfSavePath to "/Users/" & userName & "/Dropbox/OmniFocus"
set theListPerspectives to {"Active-Projects", "Active-Context", "OnHold-Projects", "OnHold-Context", "Work-Projects", "Work-Context", "Personal-Project", "Personal-Context"}

-- Need to delete files if exist as GUI scripting is not that great with replace.
set myFilePath to "Macintosh HD:Users:" & userName & ":Dropbox:OmniFocus"

repeat with theCurrentValue in theListPerspectives
	set myFile to (myFilePath & ":" & theCurrentValue & ".pdf")
	tell application "Finder"
		if exists file myFile then
			delete file myFile
		end if
	end tell
end repeat


-- Now for the script
tell application "OmniFocus"
	activate
end tell
tell application "System Events"
	tell process "OmniFocus"
		repeat with theCurrentValue in theListPerspectives
			-- This Prints out Current Name of Perspective from Perspective List and names it With PerspectiveName.pdf
			click menu item theCurrentValue of menu "Perspectives" of menu bar item "Perspectives" of menu bar 1
			click menu item "Print…" of menu "File" of menu bar item "File" of menu bar 1
			-- Click the PDF menu button
			repeat until exists sheet 1 of window 1
				delay 0.2
			end repeat
			tell sheet 1 of window 1
				click menu button "PDF"
				repeat until exists menu 1 of menu button "PDF"
					delay 0.2
				end repeat
				click menu item "Save as PDF…" of menu 1 of menu button "PDF"
			end tell
			repeat until exists (sheet 1 of sheet 1 of window 1)
				delay 0.2
			end repeat
			set myFileName to (theCurrentValue & ".pdf")
			keystroke myFileName
			delay 0.2
			keystroke "g" using {command down, shift down}
			repeat until exists sheet 1 of sheet 1 of sheet 1 of window 1
				delay 0.2
			end repeat
			tell sheet 1 of sheet 1 of sheet 1 of window 1
				set value of text field 1 to pdfSavePath
				delay 0.4
				click button "Go"
			end tell
			repeat while exists sheet 1 of sheet 1 of sheet 1 of window 1
				delay 0.2
			end repeat
			tell sheet 1 of sheet 1 of window 1
				click button "Save"
			end tell
			repeat while exists sheet 1 of sheet 1 of window 1
				delay 0.2
			end repeat
			repeat while exists sheet 1 of window 1
				delay 0.2
			end repeat
		end repeat
		
		
	end tell
end tell
Attached Files
File Type: zip Omni-PDFView-Dropbox-1.0.scpt.zip (23.2 KB, 901 views)

Last edited by Yury; 2013-04-25 at 10:25 PM..
 
Yury, thank you so much for this script. I'm Windows at work and Android tablet. Just yesterday I thought of pdf-ing my lists to Dropbox so I can access them elsewhere. I tried to create an Automator 'script' but with no success.

Your script ran first time. Now I need to figure out a way to set a chron job to run this at 5am everyday and remove the previous versions of the .pdfs.

Last edited by johnwin; 2013-01-13 at 01:44 PM..
 
One question Yury please.

If I run the script and the pdfs from a previous run are still in the Dropbox folder the mac waits for me to confirm the 'replace' requirement.

Is there a way that the script could either:

- accept the replace IF it occurs
- delete the old pdfs before printing the new ones
- add unique data to the file name, such as today's date in the format YYYYMMDD

Any ideas? Thanks again

EDIT:

Found a workaround using Text Expander but a scripted solution would be better

Last edited by johnwin; 2013-01-13 at 01:27 PM..
 
Quote:
Originally Posted by johnwin View Post
Yury, thank you so much for this script. I'm Windows at work and Android tablet. Just yesterday I thought of pdf-ing my lists to Dropbox so I can access them elsewhere. I tried to create an Automator 'script' but with no success.

Your script ran first time. Now I need to figure out a way to set a chron job to run this at 5am everyday and remove the previous versions of the .pdfs.
Sorry took some time to respond... WORK is extremely busy.

The script does this automatically, it should delete the previous version of the PDF and then create the new ones. Please let me know if it is not working for you.

The first part of the script is to Delete the PDF's, they should automatically be deleted. But I did find an error in that I duplicated the path for the script ....

Just make sure that there is only one line
set theListPerspectives to {"Active Projects", ... }

Last edited by Yury; 2013-04-25 at 10:30 PM..
 
Just spotted this one and will give it a try.

I have manually create my pdf's for a long time now mainly due to be stuck on windows at work. I often forgot to update the pdf's in my dropbox account and it was a real pain at time. Recently I changed my phone to an iphone mainly so I could have my OF database with me all the time.

Regarding removing the old pdf's another option if you have Hazel would be to have hazel monitor the pdf folder and move them automatically. ie. have the applescript generate them to your Mac's document folder and then have hazel move them to dropbox.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
On iPad how to copy Dropbox files to omni sync server? sdardens OmniOutliner for iPad 0 2013-05-02 03:50 PM
A script to print a perspective 4 pages per sheet tosz OmniFocus Extras 2 2010-10-26 03:31 PM
omni outliner annotation for omni focus robobobo OmniFocus 1 for Mac 1 2008-01-09 02:57 PM
applescript: print selected perspective steve OmniFocus Extras 1 2007-11-17 05:25 PM
Omni Focus' integration with Omni Outliner. Tinchohs OmniFocus 1 for Mac 3 2007-09-10 04:24 PM


All times are GMT -8. The time now is 02:46 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.