PDF WorkFLow

I’m trying to use the ‘PDF WorkFlow’ feature but when I try th scripts given by Apple it crashes the application that is trying to use the script. Any idea ?


on open these_items
 try
 set this_file to item 1 of these_items
 tell application "Finder"
 set the file_name to the name of this_file
 set the parent_folder to (the container of this_file) as alias
 end tell
 tell application (path to frontmost application as string)
 repeat
 display dialog "Enter a name for file:" default answer file_name
 set this_name to the text returned of the result
 if this_name is not "" then exit repeat
 end repeat
 end tell
 tell application "Finder"
 set the name of this_file to this_name
 set the target_file to ¬
 (document file this_name of the parent_folder) as alias
 end tell
 tell application "Mail"
 set the new_message to ¬
 (make new outgoing message with properties ¬
 {visible:true, content:" "})
 tell the new_message
 tell content
 make new attachment with properties ¬
 {file name:target_file} at ¬
 before the first character
 end tell
 end tell
 end tell
 on error error_message number error_number
 if the error_number is not -128 then
 tell application (path to frontmost application as string)
 display dialog error_message buttons {"OK"} default button 1
 end tell
 else
 tell application "Finder" to delete parent_folder
 end if
 end try
 end open                                   
    

I had this problem on my first attempt at PDF Workflow scripts when the feature first became available. Someone suggested saving the scripts as data fork scripts. I did and it stopped the crashes! I doubt that I would ever have discovered this by applying my normal debugging procedures.

– Rob

I’m not very ‘au fait’ of saving the script as a data fork scripts. Can this be done from Smile, or should I do it from the Script Editor (and which version of it ?), can i do it using osascript ? I’ve been able to make my script work by saving it as an applet.

I use Script Debugger and its save dialog includes the option to save as ‘Compiled Script (Data Fork)’. After some digging, I came up with this from Chris Nebel:

“In fact, Script Editor 1.9 saves all new scripts as data-fork; existing scripts are saved as whatever they were.”

– Rob

I can afford to buy SD just for getting ‘Data-fork’ scripts, and I find Se veery light, I’ll dig in ‘osascript’ manual and hopefully, i’ll find a way to do it from Smile.