This handler (see the context) gets the plain text for Custom Meta Data of type Rich Text:
on getPlainTextFromRTFDdata(theData)
try
set theNSData to (current application's NSArray's arrayWithObject:theData)'s firstObject()'s |data|()
set {theAttributedString, theError} to (current application's NSAttributedString's alloc()'s initWithData:theNSData options:(missing value) documentAttributes:(missing value) |error|:(reference))
if theError ≠ missing value then error (theError's localizedDescription() as string)
set theString to theAttributedString's |string|()
return theString as string
on error error_message number error_number
activate
if the error_number is not -128 then display alert "Error: Handler \"getPlainTextFromRTFDdata\"" message error_message as warning
error number -128
end try
end getPlainTextFromRTFDdata
As the handler uses AppleScriptObjC you need to include this at the top of your script:
use AppleScript version "2.4"
use framework "Foundation"
use scripting additions