Capture PDF document to current group

Here’s a script to convert the currently visible document view (e.g. a bookmark, a web archive, a rich text etc.) to a PDF document which is stored in the same location as the original document:


-- Capture PDF to Current Group
-- Created by Christian Grunenberg on Fri Nov 10 2006.
-- Copyright (c) 2006-2008. All rights reserved.

tell application "DEVONthink Pro"
	try
		if not (exists think window 1) or not (exists content record of think window 1) then error "No window/document is open."
		
		set theWindow to think window 1
		set theURL to URL of theWindow
		set theName to name of theWindow
		set thePDF to paginated PDF of theWindow
		if exists current group then
			set theRecord to create record with {name:theName, type:picture, URL:theURL} in current group
		else
			set theRecord to create record with {name:theName, type:picture, URL:theURL}
		end if
		set data of theRecord to thePDF
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

Just save it in the folder ~/Library/Application Support/DEVONthink Pro and it will be accessible via the Scripts menu.