Given that apparently the command line tools cannot handle converting 
highlights (from what I gathered, Skim needs the document open in a window to 
figure out what text is under the highlight regions) I cooked up the following 
AppleScript to fling the file corresponding to the record currently selected in 
DTPO at Skim for conversion (without saving) and dumping the notes to a RTF 
file. That RTF file is then passed through TextWrangler to scrub duplicate 
headings from highlight blocks not being contiguous. (Inelegant, I know, I 
could have used built in tools, but this whole script is an inelegant disaster. 
Sorry.)  
With that accomplished, the note file is yanked back into the same DTPO group 
in which the source file was found.  

If someone wanted to do this with a selected finder item instead, just rip out 
the DTPO specific parts and substitute the currently selected finder item in 
the setup at the top.  

Script follows.  


HTH!

-Dan

-------------------------------------------------------------
First, here's the important bit,  
(for those who'd like to start from scratch)
-------------------------------------------------------------


tell application "Skim"
open PATH-TO-YOUR-PDF
convert notes document 1
save document 1 in PATH-TO-TARGET-FILE as "Notes as RTF"
close document 1 saving no
end tell


----------------------------------
Here's the whole thing:  
----------------------------------

set DTSK_HLNEX_ptnf to path to desktop as string
set DTSK_HLNEX_nsfx to "-notes"
tell application "DEVONthink Pro"
set DTSK_HLNEX_the_doc to content record
set DTSK_HLNEX_doc_name to name of DTSK_HLNEX_the_doc
set DTSK_HLNEX_doc_path to path of DTSK_HLNEX_the_doc
set DTSK_HLNEX_tgt_grp to current group
set DTSK_HLNEX_tgt_db to root of current database
end tell
set DTSK_HLNEX_nfn to (DTSK_HLNEX_doc_name & DTSK_HLNEX_nsfx as string)
set DTSK_HLNEX_OF1 to (DTSK_HLNEX_ptnf & ":" & DTSK_HLNEX_nfn as string)
set DTSK_HLNEX_nfmt to ".rtf"
set DTSK_HLNEX_OF1FPN to (DTSK_HLNEX_OF1 & DTSK_HLNEX_nfmt as string)

tell application "Skim"
open DTSK_HLNEX_doc_path
convert notes document 1
save document 1 in DTSK_HLNEX_OF1 as "Notes as RTF"
close document 1 saving no
end tell


tell application "TextWrangler"
open DTSK_HLNEX_OF1FPN
set matchOptions to {match mode:leaving_one}
set outputOptions to {duplicates to new document:false, deleting 
duplicates:true}
process duplicate lines (text 1 of window 1) ¬
duplicates options matchOptions ¬
output options outputOptions
save document 1
close document 1
end tell

tell application "DEVONthink Pro"
import DTSK_HLNEX_OF1FPN name DTSK_HLNEX_nfn to DTSK_HLNEX_tgt_grp type rich
end tell

tell application "Finder"
try
delete DTSK_HLNEX_OF1FPN
end try
end tell

tell application "DEVONthink Pro"
activate
end tell

-------------------------
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Skim-app-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-users

Reply via email to