You are not logged in.
Pages:: 1
Hi all,
I have a simple script that help me in editing metadata, such as:
Applescript:
use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions
use framework "Foundation"
on run
set therecord to {Title:"LDC tile44", Author:"LDC auth44", Subject:"LDC subj44"}
set posixPath to "/Users/ldicroce/Desktop/10_1016@j_devcel_2021_12_007.pdf"
my setDocumentAttributes:therecord forPDFAt:posixPath
end run
on setDocumentAttributes:attributeRecord forPDFAt:posixPath
set thePath to current application's NSString's stringWithString:posixPath
set thePath to thePath's stringByExpandingTildeInPath()
display dialog "OK1a"
set theUrl to current application's NSURL's fileURLWithPath:thePath
display dialog "OK1b"
set thePDFDoc to current application's PDFDocument's alloc()'s initWithURL:theUrl
display dialog "OK1c"
set theDict to current application's NSDictionary's dictionaryWithDictionary:attributeRecord
thePDFDoc's setDocumentAttributes:theDict
return thePDFDoc's writeToFile:thePath
end setDocumentAttributes:forPDFAt:
And , it works perfectly.
But if I export the script as Applet, then it stops always at this line:
Applescript:
set thePDFDoc to current application's PDFDocument's alloc()'s initWithURL:theUrl
The applet has full access to the disk and folders ....
Any help to overcome this?
Thanks.
L.
Last edited by ldicroce (2022-01-25 09:24:31 am)
Offline
It seems that the applet (but not the simple Apple script [.scpt]) triggers the following error:
PDFDocument doesn’t understand the “alloc” message.
-1708
any help ?
Offline
Your script doesn't include the Quartz framework. After including that, the script saved as an app worked for me.
2018 Mac mini - macOS Monterey - Script Debugger 8
Offline
Your script doesn't include the Quartz framework. After including that, the script saved as an app worked for me.
Beautiful !!!! Thanks a million !!!
I was misguided (and I still don't understand) since the script was working fine, but the applet failed ....
Just in few words, when do I need to add use framework "Quartz" ?
Thanks again !
Offline
Just in few words, when do I need to add use framework "Quartz" ?
I have trouble remembering what requires a particular framework, so when in doubt I check the documentation. I believe I only use the Quartz framework for PDF stuff, but the documentation describes this framework as:
Allow users to browse, edit, and save images, using slideshows and Core Image filters
2018 Mac mini - macOS Monterey - Script Debugger 8
Offline
Thanks
Offline
Pages:: 1