Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > New PDF features in 10.2.4

New PDF features in 10.2.4 (Page 2)
Thread Tools
C.J. Moof
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status: Offline
Reply With Quote
Feb 20, 2003, 07:05 PM
 
Originally posted by OAW:
Thanks to the suggestion from JuanValdes above, I've found that the easiest way to send the PDF as an attachment is to simply drop an alias to Mail in the ~/Library/PDF Services. Selecting the popup menu creates the attachment as expected. However, there are two problems with this ...

1. The name of the attachment is always Print Job.pdf. There's no way to rename the attachment to something meaningful.

OAW
Sure there is- use this script. Tweaked from what was posted above to check for .pdf being tagged on the end, add it if it isn't, and leave it alone if it is.

Code:
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 "My great PDF" set this_name to the text returned of the result set this_extension to get text -1 thru -4 of the this_name if this_extension is not ".pdf" then set this_name to this_name & ".pdf" end if 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" activate 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
Be sure to save it as a compiled script, not an application.
OS X: Where software installation doesn't require wizards with shields.
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 20, 2003, 08:07 PM
 
Originally posted by C.J. Moof:
Sure there is- use this script. Tweaked from what was posted above to check for .pdf being tagged on the end, add it if it isn't, and leave it alone if it is.

Good work!

May I suggest, however, instead of getting the last four characters of the name string, just use an "ends with" comparision:

Code:
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 if this_name does not end with ".pdf" then set this_name to this_name & ".pdf" end if exit repeat end if 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
     
OAW
Addicted to MacNN
Join Date: May 2001
Status: Online
Reply With Quote
Feb 20, 2003, 09:37 PM
 
Originally posted by Sal:
Good work!

May I suggest, however, instead of getting the last four characters of the name string, just use an "ends with" comparision:

Code:
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 if this_name does not end with ".pdf" then set this_name to this_name & ".pdf" end if exit repeat end if 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
Is there anyway that the script could simply assign an attachment name based upon the name of the file itself instead of prompting the user to specifiy a name in the dialog? IOTW, if I'm in an app with a file named "XYZ.DOC" and I select "Send PDF with Mail", can it just automatically name the attachment "XYZ.PDF"?

OAW
     
C.J. Moof
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status: Offline
Reply With Quote
Feb 20, 2003, 09:47 PM
 
OK, "ends with" is a nifty option I didn't know I could use. Is there a reason that "ends with" is likely to be more robust or otherwise better than grabbing the last 4 characters and comparing?
OS X: Where software installation doesn't require wizards with shields.
     
dmanbaby
Fresh-Faced Recruit
Join Date: Feb 2003
Location: New York, NY
Status: Offline
Reply With Quote
Feb 21, 2003, 01:34 AM
 
Does anyone know how to modify the script to make it work with (egad!) Entourage? I made a few changes but all I get is an "unknown object" error from Entourage when I run the script. I'm still pretty new to this and I can't quite firgure out what the problem is.

The script (as I've changed it) is as follows:

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 "Invoice "
set this_name to the text returned of the result
if this_name is not "" then
if this_name does not end with ".pdf" then
set this_name to this_name & ".pdf"
end if
exit repeat
end if
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 "Microsoft Entourage"
set the new_message to �
(make new outgoing message with properties �
{content:" "})
tell the new_message
make new attachment with properties �
{file:target_file} at �
before the first character
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

Thanks for any insight that you might have!
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 21, 2003, 02:18 AM
 
Originally posted by OAW:
Is there anyway that the script could simply assign an attachment name based upon the name of the file itself instead of prompting the user to specifiy a name in the dialog? IOTW, if I'm in an app with a file named "XYZ.DOC" and I select "Send PDF with Mail", can it just automatically name the attachment "XYZ.PDF"?

OAW
There are a couple ways to do this, one being accessing tne name extension property. The following code snippett will extract just the actual name of an item:

Code:
set this_file to choose file tell application "Finder" set the file_name to the name of this_file set this_extension to the name extension of this_file if this_extension is not "" then set the clean_name to � text 1 thru -((length of this_extension) + 2) of the file_name else set the clean_name to the file_name end if end tell
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 21, 2003, 02:33 AM
 
Originally posted by C.J. Moof:
OK, "ends with" is a nifty option I didn't know I could use. Is there a reason that "ends with" is likely to be more robust or otherwise better than grabbing the last 4 characters and comparing?
In the end, any way that works... works. However, it's much easier to use the built-in tools than to have to write routines to do the heavy lifiting. And what if the name extension has more or less than 3 characters?

For example, here are some of the Containment Operators in AppleScript language:

start with, starts with, begin with, begins with, end with, ends with, contains, does not contain, doesn't contain, is in, is contained by, is not in, is not contained by, isn't contained by

There are also another 30 or so Comparison Operators you can use as well. These are explained in detail in the AppleScript Language Reference at this URL:

http://developer.apple.com/techpubs/...ide/index.html

Another example of how AppleScript can make things easier is using "every" and "whose" clauses to locate items instead of iterating lists of items.

Code:
tell application "Finder" to get every document file of � the entire contents of the folder "Documents" of home whose � name contains "Smith Project" and name extension is "jpg"
This statement would locate all the JPEG images in the entire hierarchy of the Documents folder whose file name contains "Smith Project." All done without a single repeat loop!
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 21, 2003, 02:51 AM
 
Originally posted by dmanbaby:
Does anyone know how to modify the script to make it work with (egad!) Entourage? I made a few changes but all I get is an "unknown object" error from Entourage when I run the script. I'm still pretty new to this and I can't quite firgure out what the problem is.

Thanks for any insight that you might have!
The syntax used by the script to create a new message and attach a file is based of the scripting terminology used by the Mail application. Every scriptable application has its own terminology which may or may not be similar to others.

To view the scripting terminology for Entourage, drag its icon onto the Script Editor icon. A dictionary window will open displaying the terms used by that app. You'll have to write the routine for creating an outgoing message using that terminology. Fortunately, there are hundreds of Entourage scripts already posted on various sites.

Try macscripter.net for starters.
     
m.brown
Dedicated MacNNer
Join Date: Jan 2002
Status: Offline
Reply With Quote
Feb 21, 2003, 06:17 AM
 
Originally posted by Sal:
[B]Good work!

May I suggest, however, instead of getting the last four characters of the name string, just use an "ends with" comparision:
Thanks for this! Is there a bug in Mail however, because the resulting PDF icon that appears in the mail message has no title - until you drag it somewhere and then release the icon, and then the name appears.

Once you e-mail it though, say to yourself, the title appears.

Any ideas?
     
OAW
Addicted to MacNN
Join Date: May 2001
Status: Online
Reply With Quote
Feb 21, 2003, 02:36 PM
 
Originally posted by Sal:
There are a couple ways to do this, one being accessing tne name extension property. The following code snippett will extract just the actual name of an item:

Code:
set this_file to choose file tell application "Finder" set the file_name to the name of this_file set this_extension to the name extension of this_file if this_extension is not "" then set the clean_name to � text 1 thru -((length of this_extension) + 2) of the file_name else set the clean_name to the file_name end if end tell
Sal,

I tried that and it's not working as I expected. It's bringing up the Choose File dialog which requires user intervention! What I'm trying to achieve is no user intervention!

IOTW ... if I simply put an alias to Mail in ~/Library/PDF Services I will get an attachment in Mail with no user intervention, however, the name of the attachment will always say printjob.pdf. I presume this is because this is the name of the spool file that is generated. Why the spool file isn't named based upon the name of the source document is beyond me, but I digress.

What I'm trying to do is to have the ease of use of the Mail alias approach, but end up with an appropriately named attachment automatically. For instance, if I'm in OmniGraffle working on a file called xyx.graffle, what I want is to automatically get an attachment called xyz.pdf without having to type a name in a dialog.

I'm not familar with Applescript at all but I do have a development background. What I can make out is that this_file in the Apple supplied script is the name of the PDF that is created from the source file. What I want is automatic access to the name of the source file itself. That way the PDF file is attached, but it's automatically named based upon the source file. Is this even possible?

OAW
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 21, 2003, 05:02 PM
 
Originally posted by OAW:
Sal,

I tried that and it's not working as I expected. It's bringing up the Choose File dialog which requires user intervention! What I'm trying to achieve is no user intervention!

IOTW ... if I simply put an alias to Mail in ~/Library/PDF Services I will get an attachment in Mail with no user intervention, however, the name of the attachment will always say printjob.pdf. I presume this is because this is the name of the spool file that is generated. Why the spool file isn't named based upon the name of the source document is beyond me, but I digress.

What I'm trying to do is to have the ease of use of the Mail alias approach, but end up with an appropriately named attachment automatically. For instance, if I'm in OmniGraffle working on a file called xyx.graffle, what I want is to automatically get an attachment called xyz.pdf without having to type a name in a dialog.

I'm not familar with Applescript at all but I do have a development background. What I can make out is that this_file in the Apple supplied script is the name of the PDF that is created from the source file. What I want is automatic access to the name of the source file itself. That way the PDF file is attached, but it's automatically named based upon the source file. Is this even possible?

OAW
Sorry about the confusion. I posted that code snippet as an example of how to work from the file name instead of asking for a name. It wasn't intended to be used as a PDF Services script.

It sounds like what you want is the PDF spool file to be named the name of the source document but with the appropriate ".pdf" name extension.

By default, PDF Services produces a spool file named generically, not based on the source document. AppleScript can access the name of the front document of the front application if the application is scriptable.

The following script will get the name of the source document if you are printing from TextEdit (scriptable) but will not work if you are printing from Preview (not scriptable).


Code:
on open these_items try -- delete the spool folder set this_file to item 1 of these_items tell application "Finder" set the parent_folder to (the container of this_file) as alias delete parent_folder end tell -- get the name of the front document tell application (path to frontmost application as text) set the doc_name to the name of the front document display dialog doc_name buttons {"OK"} default button 1 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 end if end try end open
What apps do you think you'll be printing from the most?
     
Developer
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status: Offline
Reply With Quote
Feb 21, 2003, 05:07 PM
 
Originally posted by Sal:
What apps do you think you'll be printing from the most?
Print jobs are usually named by the printing application (PMSetJobNameCFString() ). Can't a future version of PDF Services take that name for the generated PDF?
Nasrudin sat on a river bank when someone shouted to him from the opposite side: "Hey! how do I get across?" "You are across!" Nasrudin shouted back.
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 21, 2003, 05:24 PM
 
Originally posted by Developer:
Print jobs are usually named by the printing application (PMSetJobNameCFString() ). Can't a future version of PDF Services take that name for the generated PDF?
Good suggestion, I'll pass that on.
     
cacarr1
Mac Enthusiast
Join Date: Sep 2000
Location: Rock Island, IL
Status: Offline
Reply With Quote
Feb 21, 2003, 06:52 PM
 
WTF!!! i can't even get the buttons to show up!!! I've created new folder in both directories (Mac HD/Library/PDF Services & in my home directory Library/PDF Services). In those new folders, i added aliases of the Mail app, Drop stuff and Reader and still nothing!!!
what the **** am I doing wrong!
Should it work if I wanted to print a web[age for example?

Any advice is welcome.

thanks, Chris.
Uva uvam vivendo varia fit - Augustus McCrae
     
cacarr1
Mac Enthusiast
Join Date: Sep 2000
Location: Rock Island, IL
Status: Offline
Reply With Quote
Feb 21, 2003, 07:59 PM
 
Actually, I figured it out

Its all bullshit!!! You know it!!! You're a bunch a saboteurs!!!


I say to you like Zarathustra claimed off the mountain..."There is no such thing as PDF Workflow!!!"

This is a hoax!!! Nothing more.

Prove me wrong...
Chris.
Uva uvam vivendo varia fit - Augustus McCrae
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 21, 2003, 10:38 PM
 
PROBLEM SOLVED!

If you want:

1) PDF with name of source file
2) Automatically added to a new outgoing email message

this code snippet is for you! It is a Folder Actions script that can be attached to a destination folder so that when new PDF files are saved to the folder, they are processed automatically. Save the code as a compiled script and put it in: /Library/Scripts/Folder Action Scripts

Then use the Folder Actions menu items in the Script Menu to attach the script to the destination folder and also to turn on Folder Actions in the OS.

Folder Actions are described in detail here:

http://www.apple.com/applescript/folder_actions/


Code:
on adding folder items to this_folder after receiving these_items tell application "Mail" set the new_message to � (make new outgoing message with properties � {visible:true, content:" "}) tell the new_message tell content repeat with i from 1 to number of items in these_items set this_item to item i of these_items make new attachment with properties � {file name: this_item} at � before the first character end repeat end tell end tell end tell end adding folder items to
     
OAW
Addicted to MacNN
Join Date: May 2001
Status: Online
Reply With Quote
Feb 22, 2003, 05:24 AM
 
Originally posted by Sal:
PROBLEM SOLVED!

If you want:

1) PDF with name of source file
2) Automatically added to a new outgoing email message

this code snippet is for you! It is a Folder Actions script that can be attached to a destination folder so that when new PDF files are saved to the folder, they are processed automatically. Save the code as a compiled script and put it in: /Library/Scripts/Folder Action Scripts

Then use the Folder Actions menu items in the Script Menu to attach the script to the destination folder and also to turn on Folder Actions in the OS.

Folder Actions are described in detail here:

http://www.apple.com/applescript/folder_actions/


Code:
on adding folder items to this_folder after receiving these_items tell application "Mail" set the new_message to � (make new outgoing message with properties � {visible:true, content:" "}) tell the new_message tell content repeat with i from 1 to number of items in these_items set this_item to item i of these_items make new attachment with properties � {file name: this_item} at � before the first character end repeat end tell end tell end tell end adding folder items to
Sal,

Thanks for all your help! Now just what is the destination folder? Is that where the spool file goes? If so, isn't that some hidden "temp" directory buried somewhere on the HD? What happens if other things besides spooled PDF files are put in that directory?

Or does this work by saving the PDF into a designated folder that has the script attached to it?

OAW
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 22, 2003, 10:08 AM
 
Originally posted by OAW:
Sal,

Thanks for all your help! Now just what is the destination folder? Is that where the spool file goes? If so, isn't that some hidden "temp" directory buried somewhere on the HD? What happens if other things besides spooled PDF files are put in that directory?

Or does this work by saving the PDF into a designated folder that has the script attached to it?

OAW
The destination folder is the folder you create to receive the PDF files.

1) Create a folder which will contain the saved PDF files
2) Place an alias to this folder in the PDF Services folder. Rename the folder alias something like: Auto eMail PDF
3) Save the script code as a compiled script file in: Library/Scripts/Folder Action Scripts
4) Using the Folder Actions menu items in the Script menu, enable Folder Actions and attach the Folder Actions script to the folder you created

When a PDF file is saved into the Auto eMail PDF folder, the Folder Action script will be triggered and it will create a new outgoing message with the saved PDF as an attachment!
     
OAW
Addicted to MacNN
Join Date: May 2001
Status: Online
Reply With Quote
Feb 22, 2003, 03:44 PM
 
Originally posted by Sal:
The destination folder is the folder you create to receive the PDF files.

1) Create a folder which will contain the saved PDF files
2) Place an alias to this folder in the PDF Services folder. Rename the folder alias something like: Auto eMail PDF
3) Save the script code as a compiled script file in: Library/Scripts/Folder Action Scripts
4) Using the Folder Actions menu items in the Script menu, enable Folder Actions and attach the Folder Actions script to the folder you created

When a PDF file is saved into the Auto eMail PDF folder, the Folder Action script will be triggered and it will create a new outgoing message with the saved PDF as an attachment!
Sal,

Sounds like a pretty slick solution! Thanks for all your help.

OAW
     
darrick
Forum Regular
Join Date: Nov 2002
Location: at my desk, laptop on my lap
Status: Offline
Reply With Quote
Feb 23, 2003, 12:43 PM
 
adding to Sal's script something i got from Bracken's post on Apple's applescript forum, i get a script that will address mail with a pdf attachement from a watched folder:

code:


property theSender : "[email protected]"
property theName : "My Addressee"
property theAddress : "[email protected]"


on adding folder items to this_folder after receiving these_items
tell application "Mail"
set the new_message to �
(make new outgoing message with properties �
{visible:true, content:" "})
tell the new_message
set sender to theSender
make new to recipient at end of to recipients with properties {name:theName, address:theAddress}
tell content
repeat with i from 1 to number of items in these_items
set this_item to item i of these_items
make new attachment with properties �
{file name: this_item} at �
before the first character
end repeat
end tell
end tell
end tell
end adding folder items to



But.... what i want to do now is auto set the subject line to be the name of the file, so i can track what i have sent AND to auto use my signature. but how?
     
simonmartin
Mac Enthusiast
Join Date: May 2001
Status: Offline
Reply With Quote
Feb 23, 2003, 07:34 PM
 
Originally posted by Sal:
PROBLEM SOLVED!

If you want:

1) PDF with name of source file
2) Automatically added to a new outgoing email message

this code snippet is for you! It is a Folder Actions script that can be attached to a destination folder so that when new PDF files are saved to the folder, they are processed automatically. Save the code as a compiled script and put it in: /Library/Scripts/Folder Action Scripts
[/CODE]
Sal,

I have the script working pefectly except for one tiny thing: The new mail message ignores my usual signature. This is no biggie but it's weird all the same.

Simon
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 24, 2003, 01:38 AM
 
Originally posted by darrick:
But.... what i want to do now is auto set the subject line to be the name of the file, so i can track what i have sent AND to auto use my signature. but how?
Use the "info for" command to get the properties of the file and then the name from the returned properties record.

Code:
property theSender : "[email protected]" property theName : "My Addressee" property theAddress : "[email protected]" on adding folder items to this_folder after receiving these_items tell application "Mail" set the new_message to � (make new outgoing message with properties � {visible:true, content:" "}) tell the new_message set sender to theSender make new to recipient at end of to recipients � with properties {name:theName, address:theAddress} repeat with i from 1 to number of items in these_items set this_item to item i of these_items set this_info to info for this_item set the file_name to the name of this_info tell content make new attachment with properties � {file name:this_item} at � before the first character end tell set the subject to subject & the file_name & space end repeat end tell end tell end adding folder items to
     
JohnCunningham
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 24, 2003, 01:44 AM
 
Somebody asked for a similar script which sends via Entourage. I'm no script guru, but this works for me. Takes the file Print Job.pdf, prompts for a new name, adds .pdf if it's missing, and attaches to a new Entourage message.

It doesn't have some of the cleverness mentioned above (like retaining original filename), but it does show how to do the Entourage-specific scripting.
Code:
on open dropped_item set this_file to item 1 of dropped_item tell application "Finder" set the file_name to name of (info for this_file) end tell tell application "Finder" activate 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 if this_name does not end with ".pdf" then set this_name to this_name & ".pdf" end if end tell tell application "Finder" set the name of this_file to this_name end tell tell application "Microsoft Entourage" activate set the new_message to (make new draft window with properties {attachment:this_file}) end tell end open
What I would [i]really like to do is create a droplet which converts a Word doc to pdf automagically (I could then attach this to a Folder Action, creating a pdfing Drop Box). Any ideas anyone?

John
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 24, 2003, 01:45 AM
 
Originally posted by simonmartin:
Sal,

I have the script working pefectly except for one tiny thing: The new mail message ignores my usual signature. This is no biggie but it's weird all the same.

Simon
It might be because we're using the "backdoor" instead of the user interface. I'm not quite sure. But you can always add it the end of the content.

BTW, it's really great how fast you guys are picking this stuff up! AppleScript greatly expands the ablitites of Mac OS X.
( Last edited by Sal; Feb 24, 2003 at 07:14 AM. )
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 24, 2003, 02:57 PM
 
Originally posted by JohnCunningham:
Somebody asked for a similar script which sends via Entourage. I'm no script guru, but this works for me. Takes the file Print Job.pdf, prompts for a new name, adds .pdf if it's missing, and attaches to a new Entourage message.

It doesn't have some of the cleverness mentioned above (like retaining original filename), but it does show how to do the Entourage-specific scripting.

What I would [i]really like to do is create a droplet which converts a Word doc to pdf automagically (I could then attach this to a Folder Action, creating a pdfing Drop Box). Any ideas anyone?

John

John, please pardon me but I couldn't resist editing your very useful script a bit. Hope you don't mind.

Code:
on open dropped_item set this_file to item 1 of dropped_item tell application "Finder" activate set the file_name to the name of this_file set the parent_folder to the container of this_file 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 if this_name does not end with ".pdf" then set this_name to this_name & ".pdf" end if exit repeat end if end repeat set the name of this_file to this_name set this_file to (item this_name of the parent_folder) as alias end tell tell application "Microsoft Entourage" activate set the new_message to (make new draft window with properties {attachment:this_file}) end tell end open
     
darrick
Forum Regular
Join Date: Nov 2002
Location: at my desk, laptop on my lap
Status: Offline
Reply With Quote
Feb 24, 2003, 04:23 PM
 
sal, i just noticed your considerate reply to my post. thank you very much. i work on a tiBook and i send a lot of pdfs by email; this revised watched folder script will be very helpful.



Sal said in another post that he thought the default signature not appearing was caused by coming into mail by a backdoor. this was my first thought, too. but i see that signature is listed in mail's applescript dictionary. so, does anyone know: would the code for adding my signature cleverly called Signature #1 be:

set signature name {Signature #1}

but, from the dictionary entry, i don't think think it's easy to keep the fonts, etc of a signature.
     
rytc
Senior User
Join Date: Jan 2001
Status: Offline
Reply With Quote
Feb 24, 2003, 04:41 PM
 
Originally posted by Sal:
PROBLEM SOLVED!

If you want:

1) PDF with name of source file
2) Automatically added to a new outgoing email message
This is a pretty nifty little bit of code, however I was wondering whether there is someway of bypassing the folder saving part so as to only email the PDF with the correct name. The method above slowly accumulates a folder full of PDF files which while only a small problem to delete could perhaps be avoided.

Cheers Ry
     
JohnCunningham
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 24, 2003, 06:13 PM
 
Sal
Hope you don't mind
Now why would I mind? I always like to know a better way of doing things, and what's more it ain't my code once it's on the BBS

But I do have two questions
1. What does the "set the parent_folder..." + "set this_file...as alias" pairing achieve? I'm a real script newbie, so please assume ignorance.
2. Does moving the pdf extension test to inside the repeat statement make the code more efficient? Or is it convention? Or am I missing a point of logic?

Thanks,
John

PS I'd still like to know how to script the creation of a pdf using a droplet...
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 24, 2003, 07:28 PM
 
Originally posted by JohnCunningham:
Sal

Now why would I mind? I always like to know a better way of doing things, and what's more it ain't my code once it's on the BBS

But I do have two questions
1. What does the "set the parent_folder..." + "set this_file...as alias" pairing achieve? I'm a real script newbie, so please assume ignorance.
2. Does moving the pdf extension test to inside the repeat statement make the code more efficient? Or is it convention? Or am I missing a point of logic?

Thanks,
John

PS I'd still like to know how to script the creation of a pdf using a droplet...

1) In the script, the variable this_file contains a reference to the PDF spool file. Later in the script we changed the name of the spool file so it's probably safer to re-create a file reference to the newly named spool file. That's where the parent folder comes in.

2) No special reason for placing the name extension in the repeat loop other than I like to complete the actions before proceding to the next step. Just a sylistic approach.
     
kerrazyjoe
Fresh-Faced Recruit
Join Date: Feb 2003
Status: Offline
Reply With Quote
Feb 26, 2003, 12:07 AM
 
Ever since PDF Services was available I have been toying with scripts. I started early in your discussion and picked up early samples from Sal (Thanks Sal). I dug in and attempted to other things. I got stuck on copying files in the Finder - I am using PDF compress at it creates a new name name_compressed.pdf. I was weak and about eady to give up.

I went back to the discussion and paged down and sure enough - you guys had this stuff figured out. I appreciate the input and have built some pretty nifty scripts. maybe too long to post -

I wanted these
PDF to Folder
PDF to Folder Compressed
PDF to Folder Stuffed
PDF to Email
PDF to Email Compressed
PDF to Email Stuffed

I didnt want clutter the print menu so now i have
PDF to Folder
PDF to Email

And each I Have a dialog that asks for preferences compress, stuff or both

Anyway Thanks!

Does anyone here have suggestions for either PDFCompress or PDFShrinkLite
"in the middle of the nite"
Joe
     
BuonRotto
Grizzled Veteran
Join Date: Apr 2001
Status: Offline
Reply With Quote
Mar 4, 2003, 10:37 PM
 
Dragging this thread back up...

Here's why you have to love Cocoa apps and quick-thinking developers: Stone design released PStill 2.6 yesterday, which now saves presets for compression/translation of PS and PDF files on a per-folder basis. If you save a preset to a folder, then drag that folder's alias to the PDF Services folder, you can repurpose the PDF using those specific settings attached to the folder.

I have taken the folder action script above, attached it to an e-mail folder with PStill's preset "Web Output" settings saved to it, and dragged it alias into the PDF Services folder. I renamed the alias "Send repurposed PDF via Mail." Now when I choose this folder from theprint dialog pop-up, it first compresses the PDF so it's small enough for sending via e-mail, then it creates the new Mail message wit it attached.

I then created 4-up page settings in PStill and saved it as a preset into a new folder in my projects folder called "Proofs." I dragged an alias of this folder into the PDF Services folder and renamed it "Create proofs layout." I plan to add a script that will automatically print the 4-up pages a proofs.

Gawd, this stuff is so cool. Thanks to Apple for enabling it for any app, and thanks to Stone for being on the ball!
     
darrick
Forum Regular
Join Date: Nov 2002
Location: at my desk, laptop on my lap
Status: Offline
Reply With Quote
Feb 27, 2004, 03:37 AM
 
I'm curious as to whether anyone is still using these pdf services. seems like it was a big deal when it first came out, then i know i moved away from it. i use applescripts and watched folders for my pdfs, but not the pdf services. when i need to mail a pdf it is so easy to drop it on the icon (and i could never get a mail signature to automatically appear with pdf services attaching a pdf to a mail message).

so, what's up with it now?
     
Sal
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status: Offline
Reply With Quote
Feb 27, 2004, 07:13 PM
 
This thread is why we use Macs.

Thanks to Stone for continuing to contribute to the AppleScript community.

Thanks to MacNN for providing a place to swap ideas and information.

And thanks to all for your creativity and dedication to Mac OS X and AppleScript.


Sal
     
 
Thread Tools
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:00 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,