Skip to content

Instantly share code, notes, and snippets.

@fractaledmind
Created February 4, 2014 16:09
Show Gist options
  • Save fractaledmind/8806697 to your computer and use it in GitHub Desktop.
Save fractaledmind/8806697 to your computer and use it in GitHub Desktop.
Append PDFPen url of current Skim Page to selected Evernote note.
property theHome : path to home folder as string
set base1 to POSIX path of theHome & "Copy/"
set base2 to POSIX path of theHome & "Documents/PDFs/"
tell application "Skim"
set pdfTitle to name of document 1
set customurl to "pdfpen:///" & pdfTitle & "?pg="
set notePage to index of current page of document 1
set theURL to customurl & notePage
set filePath to path of document 1
if filePath does not contain base1 and filePath does not contain base2 then
--move PDF file to its proper place
set theFile to name of document 1 as string
set theFolder to choose folder default location (theHome & "Copy:" as alias) with prompt "Whither save the PDF?"
set theFolder to theFolder as string
--save as flattened pdf to be viewed by iOS app
save front document as "PDF" in (theFolder & theFile)
close document 1
open (theFolder & theFile)
go document 1 to page notePage of document 1
end if
set input to text returned of (display dialog "Title of Evernote Bookmark?" default answer "" with title "Evernote Bookmark")
set htmlURL to "<a href=\"" & theURL & "\">" & input & "</a>"
tell application id "com.evernote.Evernote"
-- append data to a note
set Evernote_Selection to selection
if Evernote_Selection is {} then display dialog "Please select a note."
repeat with i from 1 to the count of Evernote_Selection
--get appropriate note data from current note
set note1 to item i of Evernote_Selection
set noteNB to name of notebook of item i of Evernote_Selection
tell note1 to append html "<p>" & htmlURL & "</p>"
end repeat
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment