我决定鲁莽,用GMail PDF服务编写自己的Email PDF,同时学习AppleScriptObjC。我一切正常,除了实际上能够从打印对话框接受文件。
到目前为止,代码如下所示: script gmailpdfAppDelegate property parent : class "NSObject"
property recipientField : missing value
property subjectField : missing value
property fromField : missing value
property passwordField : missing value
property messageField : missing value
property pdfFile : missing value
on ButtonHandlerCancel_(sender)
quit
end ButtonHandlerCancel_
on ButtonHandlerSend_(sender)
set recipient to recipientField's stringValue()
set subject to subjectField's stringValue()
set fromUser to fromField's stringValue()
set pw to passwordField's stringValue()
set message to messageField's stringValue()
set sendEmailScript to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("sendEmail", "")) as string
set emailserverInfo to " -s smtp.gmail.com:587 -xu '" & fromUser & "' -xp '" & pw & "' -m '" & message & "' "
do shell script quoted form of sendEmailScript & " -t " & recipient & " -u " & subject & " -f '" & fromUser & "' " & emailserverInfo
quit
end ButtonHandlerSend_
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
set fromField's stringValue to do shell script "defaults read org.ryancollins.GMail-PDF 'fromDefault'"
set passwordField's stringValue to do shell script "security 2>&1 >/dev/null find-generic-password -ga gmailpdf |ruby -e 'print $1 if STDIN.gets =~ /^password: \"(.*)\"$/'"
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
set fromDefault to fromField's stringValue()
do shell script "defaults write org.ryancollins.GMail-PDF 'fromDefault' '" & fromDefault & "'"
set passwordDefault to passwordField's stringValue()
do shell script "security add-generic-password -a gmailpdf -s email -p '" & passwordDefault & "' -U"
return current application's NSTerminateNow
end applicationShouldTerminate_
end script
编译并添加到 PDF Services 文件夹时,我收到此错误(该应用程序名为 GMail PDF:
The document “Google News.pdf” could not be opened. GMail PDF cannot open files in the “Portable Document Format (PDF)” format.
如何让 AppleScriptObjC 应用程序接受该文件?