I'm assembling an XML metadata record in AppleScript (using Satimage's XMLLib). Since XML contains lots of double quote marks, there are lots of escaped quotes (\") in the string variable containing the record.
To insert the metadata into a PDF file, Acrobat offers the AppleScript command: do script "some _javascript_ code"
When I try this: set the_JavaScript to "this.metadata = " & my_XML_string & ";"
tell application "Adobe Acrobat Professional" to tell active doc to do script the_JavaScript
I get: "Acrobat got an error: "this.metadata = <my XML stuff including escaped quotes>;" doesn't understand the do script message".
I believe the exact actual string that Acrobat's _javascript_ interpreter wants to see is like this (WITHOUT overall enclosing quotes): this.metadata = "<metadata XML>;"
including the quote marks.
I suspect the \" escaped quotes are messing up the _javascript_ interpreter but I don't know how to get rid of them.
By the way, this works fine to extract the XML string from the PDF: tell application "Adobe Acrobat Professional" to tell active doc to do script "this.metadata;" set the_XML_string to the result
Thoughts? |