My PDF-file has custom metadata. Imprint via GUI works OK — it inserts custom metadata as placeholders.
How can I make imprint to PDF with custom metadata via AppleScript?
Please help to add custom metadata to my script
tell application id "DNtp"
set theSelection to the selection
if (count of theSelection) is 1 then
set theRecord to the content record
imprint font "Times New Roman Italic" position top center record theRecord size 15 text "Some text"
end if
end tell
Have you set up an imprint configuration in Preferences > Imprinter ?
If not, I suggest you start there.
Once you’ve established an imprint configuration, you could hard code it into a script or as an alternative, allow choosing an imprint to apply. Here’s a simple example of the latter…
tell application id "DNtp"
repeat with thisFile in (selection as list)
set recordType to (type of thisFile as string)
if (recordType = "PDF document") or (recordType = "image") then
set imprinterList to (get imprinter configuration names)
set chosenImprint to choose from list imprinterList
imprint configuration (item 1 of chosenImprint) to thisFile
end if
end repeat
end tell
PS: I suggest you enable Duplicate item before imprinting in Preferences > Imprinter, at least while you’re testing. This will preserve the original file and imprint a copy.
No there is currently no way from DEVONthink to sync the imprinter settings. You could manually transfer it but DEVONthink on the receiving machine should be closed before replacing the file.
Dear All, thanks for your replies. All the answers helped me to choose method (I choose Applescript + Keyboard Maestro), and to make my Applescript.
We used to use different complicated imprints via Graphic User Interface for our sells and shippings. Everything works OK. The only problem was to synchronize imprint configurations between macs.
Also we use Keyboard Maestro, which make synchronization for macros between our macs.
Now I made my macros with Applescript, and macros are synchronized!
Here is example of Applescript for Keyboard Maestro
tell application id "DNtp"
set theSelection to the selection
if (count of theSelection) is 1 then
set theRecord to the content record
set recordType to (type of theRecord as string)
if (recordType = "PDF document") then
set recordCarrier to get custom meta data for "carrier" from theRecord
set myText to "Carrier: " & recordCarrier
imprint font "Times New Roman Italic" position top center record theRecord size 15 text myText -- Add here some formatting
return myText
else
return "Select PDF file"
end if
else
return "Select one PDF file"
end if
end tell