I need to inject metadata in PDF’s generated from Illustrator CS3 and Indesign CS3
I don’t see any way to do this in illustrator and I haven’t gotten to indesign yet could anyone tell me if I’m missing something or if they know of any way to do this ?
Its been a while but I recall looking at metadata in illustrator and there being non. You can add it afterwards in ‘Bridge’ using append and replace templates. If you require adding specific info on a file by file basis then you would need to look for a JavaScript solution.
thank you it’s good to know I’m not crazy I have started looking into doing this via javascript and it is pretty straight forward. Though I am having an issue with running js in my apple script you can see thread http://macscripter.net/viewtopic.php?id=30805 when I get everything sorted I’ll post back to this thread how to inject the metadata
Some of our customers are quite picky about the metadata appearing in the PDF files we deliver to them. That’s why I wrote a small command line utility to help me and my colleagues out.
The tool - named pdfprops - can modify the metadata values for author, title, subject, creator and keywords. You can download it for free right here.
As most of my colleagues in the print department do not like to use command line tools in the Terminal I wrote them a convenient small AppleScript droplet, which you can see below.
You can set the metadata values to be injected into dropped PDF files with the properties found at the very beginning of the script code. If you do not want to delete an existing metadata value, just set the value for this property to missing value.
Just in case you are interested in the original source code of the compiled pdfprops utility, you can study it right here.
Happy Scripting!
property mytitle : "pdfprops"
-- path to the pdfprops command line utility
property ftooplath : missing value
-- metadata to be injected
-- >> set a property value to «missing value» to ignore it
property author : "Martin Michel"
property title : "AppleScript - The mutant language from the moon!"
property subject : missing value
property creator : "A wonderful Mac application"
property keywords : "Computer science,Apple,Macintosh"
-- I am called when the user opens the script with a double-click
on run
tell me
activate
display dialog "Drop PDF files onto my icon to modify their metadata." & return & return & "You can set the metadata values to be injected by opening this script with the AppleScript-Editor." buttons {"OK"} default button 1 with icon note with title mytitle
end tell
end run
-- I am called when the user drops Finder items onto the script
on open finderitems
try
-- searching for dropped PDF files...
set pdffiles to {}
repeat with finderitem in finderitems
set finderiteminfo to (info for finderitem)
if (not folder of finderiteminfo) and (name of finderiteminfo ends with ".pdf") then
set pdffiles to pdffiles & finderitem
end if
end repeat
-- no PDF files found :-(
if pdffiles is {} then
error "You did not drop any PDF files onto the script." number 420001
end if
-- locating the pdfprops command line utility
if not my itempathexists(ftooplath) then
set ftoolpath to (choose file with prompt "Please locate the pdfrops command line utility:" without invisibles and multiple selections allowed) as text
end if
-- creating quoted arguments
set qtdftoolpath to quoted form of POSIX path of ftoolpath
set keyvalues to {author, title, subject, creator, keywords}
set keynames to {" -author ", " -title ", " -subject ", " -creator ", " -keywords "}
repeat with i from 1 to 5
set keyvalue to item i of keyvalues
if keyvalue is not missing value then
set keyname to item i of keynames
set argument to keyname & quoted form of keyvalue
set arguments to arguments & argument
end if
end repeat
-- processing the found PDF files
repeat with pdffile in pdffiles
set qtdpdffilepath to quoted form of POSIX path of (pdffile as text)
set command to qtdftoolpath & " -file " & qtdpdffilepath & arguments
try
do shell script command
on error errmsg number errnun
error errmsg number errnum
end try
end repeat
on error errmsg number errnum
my dsperrmsg(errmsg, errnum)
end try
end open
-- I am indicating if an itempath really exists
on itempathexists(itempath)
try
set itemalias to itempath as alias
return true
on error
return false
end try
end itempathexists
-- I am displaying error messages to the user
on dsperrmsg(errmsg, errnum)
tell me
activate
display dialog "Sorry, an error occurred:" & return & return & errmsg & "(" & errnum & ")" buttons {"OK"} default button 1 with icon stop with title mytitle
end tell
end dsperrmsg
thank you so much for sharing your script and the pdfprops tool “ I’ve been looking for something like this!
Just in case anyone else tries it out:
a) I had to unify the variable “ftooplath” to “ftoolpath” and
b) added an extra line: “set arguments to {}”
to make the script run.
Another hint: If you place the pdfprops tool in the application folder
you may define the property “ftoolpath” like this:
property ftoolpath : (path to applications folder as string) & "pdfprops"
Thanks a lot again!
Claus
Here is my adapted version of the script:
property mytitle : "pdfprops"
-- path to the pdfprops command line utility
--property ftooplath : missing value
property ftoolpath : (path to applications folder as string) & "pdfprops"
-- metadata to be injected
-- >> set a property value to «missing value» to ignore it
property author : "" -- insert your data
property title : "" -- insert your data
property subject : "" -- insert your data
property creator : "" -- insert your data
property keywords : "" -- insert your data
-- I am called when the user opens the script with a double-click
on run
tell me
activate
display dialog "Drop PDF files onto my icon to modify their metadata." & return & return & "You can set the metadata values to be injected by opening this script with the AppleScript-Editor." buttons {"OK"} default button 1 with icon note with title mytitle
end tell
end run
-- I am called when the user drops Finder items onto the script
on open finderitems
try
set arguments to {}
-- searching for dropped PDF files...
set pdffiles to {}
repeat with finderitem in finderitems
set finderiteminfo to (info for finderitem)
if (not folder of finderiteminfo) and (name of finderiteminfo ends with ".pdf") then
set pdffiles to pdffiles & finderitem
end if
end repeat
-- no PDF files found :-(
if pdffiles is {} then
error "You did not drop any PDF files onto the script." number 420001
end if
-- locating the pdfprops command line utility
if not my itempathexists(ftoolpath) then
set ftoolpath to (choose file with prompt "Please locate the pdfrops command line utility:" without invisibles and multiple selections allowed) as text
end if
-- creating quoted arguments
set qtdftoolpath to quoted form of POSIX path of ftoolpath
set keyvalues to {author, title, subject, creator, keywords}
set keynames to {" -author ", " -title ", " -subject ", " -creator ", " -keywords "}
repeat with i from 1 to 5
set keyvalue to item i of keyvalues
if keyvalue is not missing value then
set keyname to item i of keynames
set argument to keyname & quoted form of keyvalue
set arguments to arguments & argument
end if
end repeat
-- processing the found PDF files
repeat with pdffile in pdffiles
set qtdpdffilepath to quoted form of POSIX path of (pdffile as text)
set command to qtdftoolpath & " -file " & qtdpdffilepath & arguments
try
do shell script command
on error errmsg number errnun
error errmsg number errnum
end try
end repeat
on error errmsg number errnum
my dsperrmsg(errmsg, errnum)
end try
end open
-- I am indicating if an itempath really exists
on itempathexists(itempath)
try
set itemalias to itempath as alias
return true
on error
return false
end try
end itempathexists
-- I am displaying error messages to the user
on dsperrmsg(errmsg, errnum)
tell me
activate
display dialog "Sorry, an error occurred:" & return & return & errmsg & "(" & errnum & ")" buttons {"OK"} default button 1 with icon stop with title mytitle
end tell
end dsperrmsg