A Better Save PDF to Yojimbo Script

In Part I of this article, I provided instructions for an AppleScript, to be used in conjunction with Quicksilver, to help you easily import items (PDFs, txt and web links) from the Desktop or Finder into Yojimbo, tag and file them into the relevant folder collections, all in one action. In this tutorial I will explain how a similar script can be used in conjunction with the Save PDF to Yojimbo option from the PDF Services drop-down list in the Print dialog.

You can easily save documents as PDFs and import them into your Yojimbo database. Simply choose Print from within an application, click the PDF button (in the left hand corner of the Print dialog box) and select Save PDF in Yojimbo from the drop-down list.

This is especially useful when you want to add a file to your Yojimbo database that is not in a supported format (Microsoft Word documents are a good example - while they can be imported they tend to display incorrectly). I use the Save PDF to Yojimbo function frequently when saving PDF copies of web invoices and web pages.

The shortcoming of importing data into Yojimbo using this method, like those described in Part I, is that you need to go back into Yojimbo to tag and file the PDF into the right folder collection(s).

In this tutorial I will explain how to write an AppleScript that will allows you to name, tag and file the PDF all in one action. This will streamline your workflow and hopefully ensure that your Yojimbo database exhibits some semblance of order.

Disclaimer: I must profess that this script is not my work. I have merely put together two separate bits of code (provided by Steve Kalkwarf and Kenneth Kirksey in a thread at Yojimbo Talk) and added a few minor changes. It is a great little script that I think many will find useful so I wanted to share it.

Installation

  1. Open Script Editor, found in Applications/AppleScript/
  2. Copy the code below and paste it into a new script window.
  3. Name the script Copy to Yojimbo and File and save the script as a script in Macintosh HD/Users/YourAccount/Library/PDF Services/ (where ‘YourAccount’ is the name of your user account on your Mac).
  4. You’re done!

Code

----------------------------------------------------------
-- Save PDF to Yojimbo and Tag
--
-- Allows you to rename, tag and file (into your folder collections)
-- an item into Yojimbo using Print to PDF.
--
-- Save as a application to ~Library/PDF Services.
----------------------------------------------------------
on open (theFile)

	----------------------------------------------------------
	-- set chooseTagsfromList to true if you want
	-- the script to present you with a list
	-- of tags to pick from. Set it to false if you want
	-- to manually enter the tags.
	-- If you manually enter tags, separate tags
	-- with commas.
	----------------------------------------------------------
	-- set chooseCollectionsFromList to true if you want
	-- the script to present you with a list
	-- of folder collections to pick from.
	----------------------------------------------------------
	-- set chooseTheName to true if you want
	-- the script to present you with a dialog box
	-- where you can set the name of the PDF.
	----------------------------------------------------------

	set chooseTagsFromList to true
	set chooseCollectionsFromList to true
	set chooseTheName to true

	if chooseTheName then
		set theName to text returned of (display dialog "Name:" default answer "")
	end if

	if not chooseTagsFromList then
		set restoreDelimiters to AppleScript's text item delimiters

		set AppleScript's text item delimiters to ","
		set theTags to text returned of (display dialog "Tags:" default answer "")

		set the chosenTagList to every text item of theTags
	end if

	tell application "Yojimbo"

		set allTags to name of every tag
		if chooseTagsFromList then
			set chosenTagList to choose from list allTags ¬
				with title ¬
				"Tags" with prompt ¬
				¬
					"Choose Tags:" multiple selections allowed true ¬
				with empty selection allowed
		end if

		set allCollections to (name of every folder collection)
		if chooseCollectionsFromList then
			set chosenCollectionList to choose from list allCollections ¬
				with title ¬
				"Collections" with prompt ¬
				¬
					"Add PDF to which collection?" multiple selections allowed true ¬
				with empty selection allowed
		end if

		set n to import theFile

		if chooseTheName then
			set name of n to theName
		end if

		add tags chosenTagList to n
		repeat with i from 1 to the count of chosenCollectionList
			add n to folder collection named (item i of chosenCollectionList)
		end repeat

	end tell

	if not chooseTagsFromList then
		set AppleScript's text item delimiters to restoreDelimiters
	end if
end open

Script Modifications

  • If you want to manually add tags (similar to the way you would in del.ico.us) then set chooseTagsFromList to false
  • If you don’t want the code to present you with a dialog box so you can rename the PDF then set chooseTheName to false.
  • If you don’t want to choose folder collections then set chooseCollectionsFromList to false.

How to Use

  1. In any application in which you want to save the file as a PDF select Print from the File menu.
  2. The Print dialog will be displayed.
  3. Click the PDF button located in the bottom left of the dialog box.
  4. Select Save PDF to Yojimbo and File.app
  5. The Yojimbo dock icon should bounce. ALT-TAB to the Save PDF to Yojimbo application.
  6. You will be presented with a dialog box asking you to name the PDF. Enter a name and click OK.
  7. You will then be presented with a window titled Tags with your Yojimbo tags listed. You can select as many tags as you like by holding down the Command key and clicking the tag names. Alternatively, you don’t have to select any tags. Once you have done that click OK.
  8. A window titled Collections will ask you which collection(s) you would like to add the item to. Again you can select zero, one or multiple collections. Click OK once you’re done.
  9. Your item will have been imported into Yojimbo, added to the collections you selected and tagged as you selected.

Suggestions for Improvement

In Part 1 I listed some ideas for improvements. These included the option to add flags and an option to encrypt. I think both improvements would be useful here also.

Again, I must reiterate that I am not a programmer and that if anyone out there in the ‘inter-web’ could help us at MLS add these features we would be most appreciative. :)

Comments

Comment on this post (no registration required) in the Mac Law Students Forum.