Import PDF of Current Page in OmniWeb

I like to have PDFs of articles I find online so that can annotate them in Skim. This script imports the current page as a PDF in DTP, providing the option to rename the file and add comments. (To clarify, this for regular web pages, not PDFs that are being viewed in OW–I know that there are scripts on the forum for the latter, but could not find any for the former)


-- Options
property destGroup : "/Web PDFs" --Default location
property growlNotif : true --Growl notification
property addTag : true --Add comments on import

tell application "OmniWeb"
		if not (exists browser 1) then error "No browser is open."
		-- Setting initial variables
		set theBrowser to front browser
		set theName to the name of theBrowser
		set theURL to the address of theBrowser
		if addTag is true then
			set getTags to display dialog ¬
				"Record Name: " & return & theName default answer ¬
				"Enter Comments" buttons {"Rename", "Cancel", "OK"} ¬
				default button "OK" with title "Set Tags"
			-- Option to change the proposed name
			if (button returned of getTags) is "Rename" then
				--Titlecase the page name
				set theName to do shell script "python -c \"import sys; print unicode(sys.argv[1], 'utf8').title().encode('utf8')\" " & quoted form of theName
				set newName to display dialog ¬
					"New Name:" default answer (theName) ¬
					buttons {"Cancel", "OK"} ¬
					default button 2 with title "Set New Name"
				set theName to text returned of newName
			end if
			set theComment to text returned of getTags
			if theComment is "Enter Comments" then set theComment to ""
		end if
		set theSource to do script "document.documentElement.outerHTML" window browser 1
	end try
end tell

tell application "DEVONthink Pro"
		if not (exists current database) then error "Please open a database before using this script!"
		set incomingGroup to create location destGroup
		set archive to create record with {name:theName, type:html, URL:theURL, source:theSource} in incomingGroup
		set theWindow to open window for record archive
		delay 2.0
		set thePDF to PDF of theWindow
		set theRecord to create record with {name:theName, type:picture, URL:theURL, comment:theComment} in incomingGroup
		set data of theRecord to thePDF
		close theWindow
		delay 1.0
		delete record archive
		if growlNotif is true then my growlNotification("DEVONthink Pro", "PDF Capture", "Page Added to Database")
	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

on growlNotification(growlIcon, growlTitle, growlDescrip)
	if application "GrowlHelperApp" is running then
		set appName to "MattsNotif"
		set notifs to {growlTitle}
		tell application "GrowlHelperApp"
			register as application ¬
				appName all notifications notifs ¬
				default notifications notifs ¬
				icon of application growlIcon
			notify with name growlTitle title growlTitle description growlDescrip application name appName
		end tell
	end if
	return ""
end growlNotification