I’m new to devonthink and applescript and I try to automate my workflow. When I work on pdf’s, I normally add stamps to the pdf using PDFPen. (e.g. “Paid” or other stamps)
My Idea was to have a button (applescript) in DTPO to automate the process:
Open PDF in PDFPen
Add Stamp
Close and Save PDF
I tried to solve this in applescript. But I was not able to pass the pdf selected in DTPO to PDFPen using AppleScript.
Could someone give me an advice how to solve the issue?
tell application id "DNtp"
set theSelection to the selection
if (count of theSelection) is 1 then
set thePath to path of item 1 of theSelection
if thePath ends with ".pdf" then tell application "PDFpenPro" to open (POSIX file thePath) as alias
end if
end tell
This is a nice automated solution for adding stamps to PDFs from within DT using PDFPen Pro
--list of {red, green, blue, alpha} in range 0 to 65535
set foregroundcolor to {65535, 65535, 65535}
set backgroundcolor to {65500, 0, 0}
tell application id "DNtp"
set theSelection to the selection
if (count of theSelection) is 1 then
set dialog_reply to display dialog "Enter stamp:" default answer ""
set impromptu to text returned of dialog_reply
set thePath to path of item 1 of theSelection
if thePath ends with ".pdf" then
tell application "PDFpenPro"
open (POSIX file thePath) as alias
set thePage to page 1 of document 1
set the_height to height of thePage
set the_width to width of thePage
set theImprint to (make new text imprint at end of imprints of thePage with properties {rich text:impromptu, x position:(the_width - 150), y position:(the_height - 50), height:30, width:540, background color:backgroundcolor)
set font of attribute run 1 of rich text of theImprint to "Arial"
set size of attribute run 1 of rich text of theImprint to 24
set color of attribute run 1 of rich text of theImprint to foregroundcolor
delay 0.5
try
close document 1 saving yes
end try
end tell
end if
end if
end tell