 |
 |
New PDF features in 10.2.4
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: Kansas City, Mo
Status:
Offline
|
|
http://www.apple.com/applescript/print/
This looks really cool. I enabled the hidden buttons but don't see the menu items or scripts in the pop down list.
Anyone know if these are just examples that Apple made up or do they exist? The PDF compress script initially interests me.
(Last edited by kcmac; Feb 14, 2003 at 12:00 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Aug 2002
Location: Cardboard Box
Status:
Offline
|
|
I think this ahs bees around a while hasn't it? Very cool though. 
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: Kansas City, Mo
Status:
Offline
|
|
Hopefully it has been. This may mean the scripts are real. I would like to find them. 
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Dec 2000
Status:
Offline
|
|
"Save as PDF..." isn't new. Might have been around since 10.2, but definitely by 10.2.1 and later.
|
|
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Jun 2001
Location: Melbourne, Australia
Status:
Offline
|
|
Originally posted by fulmer:
"Save as PDF..." isn't new. Might have been around since 10.2, but definitely by 10.2.1 and later.
Indeed, but this new 'Process PDF' feature IS new. I want the compress PDF feature, too!!!
|
|
Computer thez nohhh...
|
| |
|
|
|
 |
|
 |
|
Posting Junkie
Join Date: Nov 2001
Location: Retired.
Status:
Offline
|
|
I want to know this as well, odd that nobody knows and Apples site isn't "more friendly"....
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2001
Location: Kansas City, Mo
Status:
Offline
|
|
Trying to revise the title of this thread since it is somewhat confusing. I have attempted to edit it several times with no luck. Advice?
|
|
|
| |
|
|
|
 |
|
 |
|
Admin Emeritus 
Join Date: Oct 1999
Location: Zurich, Switzerland
Status:
Offline
|
|
[I deleted responses to this, renamed the thread.]
You can't. Only moderators can edit thread titles. (It involves the "edit thread" feature that normal users don't get.)
tooki
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2001
Location: Seattle, WA
Status:
Offline
|
|
your other thread made 1000x more sence and this is a sweet new feature! 
|
|
The spirit of resistance to government is so valuable on certain occasions, that I wish it always to be kept alive.
- Thomas Jefferson, 1787
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2000
Status:
Offline
|
|
I want the compress PDF feature, too!!!
a) you actually need to install something like apago's pdfshrink lite
b) then create a directory:
/Library/PDF Services
and
~/Library/PDF Services
c) and then put an alias to apps like pdfshrink lite and acrobat in that folder.
then the menu will show up. according to the docs you only need one of those folders, but i had to create both to get it working. also, if you don't have a valid printer setup it won't create the spool file (pdf file) to pass to those apps and will instead report an error.
the bottom line is that you can put an alias to any app, applescript, or cli tool that can process pdf files into the "/Library/PDF Services" and/or "~/Library/PDF Services" folder and that's how you enable the menu.
whatever you name the alias is what will show up in the menu.
it's pretty cool once you get it working.
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2000
Status:
Offline
|
|
|
(Last edited by tooki; Feb 16, 2003 at 01:41 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
You can do any or all of four types of actions:
1) place an alias to a folder in the PDF Services folder and it becomes a destination for the saved PDF file
2) place an alias to an application in the PDF Services folder and it will allow you to open the saved PDF file with the aliased application
3) place a UNIX tool in the PDF Services folder and it will execute with the saved PDF
4) place a compiled script or an alias to a compiled script in the PDF Services folder and it will execute
(the menu items shown below are for illustration)
Make sure your scripts have an "on open" handler to receive file refs to the saved PDF files. An example script is on the webpage. Copy this script and paste it into the Script Editor and save it as a script file. The example script will create a new email with the saved PDF file as an attachment!
Here's another version of the same email script:
Code:
on open 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 the count of these_items
set this_file to item i of these_items
make new attachment with properties ¬
{file name:this_file} at ¬
before the first character
end repeat
end tell
end tell
end tell
end open
FOR UNIX TOOL:
A tool is a file that is not an application and has at least one execute bit set. Tools can be written in C, Perl, Python, Bash, or using any other language that can create an executable file.
A UNIX tool or tool alias triggers an action by the tool on the PDF file. Tools are passed three parameters:
1) the title of the PDF document
2) a string that specifies the CUPS options for the job
3) the path to the spooled PDF file
The tool can perform any processing based on these parameters, usually creating a new file, and then the tool should delete the spooled PDF file.
Example:
The code listing shown here defines a script that executes the pdfcrypt tool available from http://www.sanface.com/pdfcrypt.html .
This code encrypts the PDF file with the password "snooker". Once the new encrypted file is created, it is opened in Preview which prompts the user for the password.
Note:
The pdfcrypt tool requires a registration fee which you must pay before you use it. It is shown here simply as an example.
Code:
#!/bin/sh
#
# usage: cryptpdf title options inputfile
#
/usr/bin/pdfcrypt -input="$3" -output="/Users/sal/$1.pdf" -pass="snooker"
open -a "Preview" "/Users/sal/$1.pdf"
rm "$3"
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2003
Location: 127.0.0.1
Status:
Offline
|
|
That sample attachment script does not work. Instead, I get an error saying that the application (Mail) is not scriptable.
Anything I am doing wrong?
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
Originally posted by alphasubzero949:
That sample attachment script does not work. Instead, I get an error saying that the application (Mail) is not scriptable.
Anything I am doing wrong?
Try this: drag the Mail icon onto the Script Editor icon. If the dictionary window for Mail opens, the app is fine. If not, you may have an old version of Mail.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Jan 2003
Location: 127.0.0.1
Status:
Offline
|
|
The dictionary window does open. However I still get the same error:
Could not read the dictionary of the application or extension because it is not scriptable.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Mar 2001
Location: Seattle, WA
Status:
Offline
|
|
Originally posted by alphasubzero949:
The dictionary window does open. However I still get the same error:
Could not read the dictionary of the application or extension because it is not scriptable.
I just made a alias to mail.app and put it in the folder. It will create a new email and attatch the pdf.
And for the dude a few posts up, I'm not sure what was wrong with your system but on two differnt macs here just making the folder in ~/Library/ worked fine. Maybe that is the key one?
dono, but this is ****ing sweet 
|
|
The spirit of resistance to government is so valuable on certain occasions, that I wish it always to be kept alive.
- Thomas Jefferson, 1787
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Oct 2000
Location: Alpharetta, GA
Status:
Offline
|
|
Originally posted by alphasubzero949:
The dictionary window does open. However I still get the same error:
Could not read the dictionary of the application or extension because it is not scriptable.
Sal, do you need to download "scripting additions" to put in /Library for this to work, or is it automagic?
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2000
Status:
Offline
|
|
juanvaldes:
And for the dude a few posts up, I'm not sure what was wrong with your system but on two differnt macs here just making the folder in ~/Library/ worked fine. Maybe that is the key one?
you might be right. i put the aliases in /Library/PDF Services but the menu didn't show up until i created an empty ~/Library/PDF Services. i actually didn't try it the other way. i just assumed.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Apr 2001
Location: under about 12 feet of ash from Mt. Vesuvius
Status:
Offline
|
|
This is a very handy extension of the system, I wonder why Apple haven't made it a bit more user friendly to execute? Could just include it in the system update.
Well it isn't that hard to set up really what am I saying. 
|
|
i look in your general direction
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2000
Status:
Offline
|
|
How do you get all those commands listed it the Print Window;
Compress to PDF to Send PDF via Mail
Thanks
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status:
Offline
|
|
Originally posted by BobW:
How do you get all those commands listed it the Print Window;
Compress to PDF to Send PDF via Mail
Place an alias to the respective application into the folder ~/Library/PDF Services/
To mail for example place an alias to Mail.app into this folder (and call it "Send PDF via Mail").
|
|
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.
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Mar 2000
Status:
Offline
|
|
Developer:
Place an alias to the respective application into the folder ~/Library/PDF Services/
To mail for example place an alias to Mail.app into this folder (and call it "Send PDF via Mail").
creating an alias will do the job for apps that know how to open pdf.
acrobat, pdfshrink, pdfenhancer, text edit...etc.
if you want mail.app to mail the pdf file, you need to use a droplet applescript like what sal has described. the applescript will take the open file event and translate it into something meaningful for mail.app.
finally, if you place an alias to a cli tool or shell script, the tool will execute and will be passed the pdf file's path, it's title, and the cups parameters...etc, and can then use that information to process the file.
apple has docs fully explaining the process which haven't been released yet.
BobW:
How do you get all those commands listed it the Print Window;
Compress to PDF to Send PDF via Mail
for "send pdf via mail" use the applescript that sal posted above.
for "compress pdf" you need a tool that can compress pdf's and then create the appropriate alias.
the menu will show the title of the alias or applescript in the PDF Services folder.
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status:
Offline
|
|
Originally posted by nibs:
if you want mail.app to mail the pdf file, you need to use a droplet applescript like what sal has described. the applescript will take the open file event and translate it into something meaningful for mail.app.
Actually, no. The alias is sufficient and does exactly the same as the script.
But I can understand that for Sal writing the script is faster than creating an alias. 
|
|
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.
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Jun 2000
Status:
Offline
|
|
Ok, I'm still lost here.
I use Eudora, so I put an alias of that in and it works.
But how do I get CompressPDF in ther?
Thanks
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status:
Offline
|
|
Originally posted by BobW:
But how do I get CompressPDF in ther?
It's the same principle. You write an AppleScript that scripts whatever app you use to compress PDF (Adobe Acrobat most likely) and drop it in that folder. You can use Sal's example script as a template.
If you have a simple tool that just compresses PDF you could likely just drop an alias to that into the PDF Services folder.
|
|
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.
|
| |
|
|
|
 |
|
 |
|
Grizzled Veteran
Join Date: Apr 2001
Status:
Offline
|
|
This is very cool! I haven't written any scripts, just dropped some aliases in the new PDF Services folder, renamed them, and voilá! I'll probably whip up a few scripts to encrypt the PDFs too.

|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Santa Monica, CA
Status:
Offline
|
|
Originally posted by Developer:
Actually, no. The alias is sufficient and does exactly the same as the script.
But I can understand that for Sal writing the script is faster than creating an alias.
I've got the alias in there, and it is showing up in the new menu, but as the print process begins, I get an error message that is quite useless -- "Error while Printing" -- and that is the end of it...
any ideas? Thanks!
|
|
"Labor is prior to, and independent of, capital. Capital is only the fruit of labor, and could never have existed if labor had not first existed. Labor is the superior of capital, and deserves much the higher consideration." -- Abraham Lincoln, 1861
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Jan 2001
Location: Zurich, Switzerland
Status:
Offline
|
|
Originally posted by brachiator:
I've got the alias in there, and it is showing up in the new menu, but as the print process begins, I get an error message that is quite useless -- "Error while Printing" -- and that is the end of it...
any ideas? Thanks!
I think someone mentioned this above but you need to have a valid printer setup to use this. In whatever app you're in select "Page Setup" then select "edit printer list" under the printer pull down menu. Printer App will open, then select "IP printing" and type in localhost as the printer address Ok and then it should now work for you.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Dec 2002
Status:
Offline
|
|
Originally posted by Sal:
You can do any or all of four types of actions:
1) place an alias to a folder in the PDF Services folder and it becomes a destination for the saved PDF file
2) place an alias to an application in the PDF Services folder and it will allow you to open the saved PDF file with the aliased application
etc.
All very cool. But we're still not quite there. How can I call one of these new actions with applescript? The new UI scripting features seem to be getting us close. But I can't see how to fully automate this. Ultimately I want FileMaker to be able to select a printer, a preset, and or one of these new PDF options, hands off.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
Here's a script that will:
1) rename the spool file
2) create a Stuffit archive with the PDF (password protection optional)
3) create an new outgoing message in Mail with the archive as an attachment
4) reveal the archive file in the Finder
Enjoy!
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 exit repeat
end repeat
display dialog "Enter a password for the archive:" & ¬
return & return & ¬
"(Leave blank for no password)" default answer ""
set this_password to the text returned of the result
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
set the archive_name to this_name & ".sit"
set this_archive to ((parent_folder as string) & the archive_name)
tell application "StuffIt Deluxe"
launch
set the new_archive to ¬
make new archive with properties {location:file this_archive}
if this_password is "" then
stuff target_file into the new_archive
else
stuff target_file into the new_archive password this_password
end if
close archive window archive_name
end tell
set this_archive to alias this_archive
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:this_archive} at before first character
end tell
end tell
end tell
tell application "Finder"
reveal document file this_archive
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 this_folder
end if
end try
end open
(Last edited by Sal; Feb 16, 2003 at 07:58 AM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Nov 2002
Location: at my desk, laptop on my lap
Status:
Offline
|
|
thanks for the script!!
i noticed that while using this script or using the mail alias the entire doc gets pdf'd; that i cannot just print page 1 to 1 as a pdf.
anyone else have this happen??
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
Move to Chosen Folder
This script will prompt you for a destination for the PDF file and move the spool file to the chosen location.
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
repeat
tell application (path to frontmost application as string)
set this_folder to ¬
choose folder with prompt "Choose a location for the file:"
end tell
tell application "Finder"
set exists_flag to exists item file_name of this_folder
end tell
if exists_flag is true then
tell application (path to frontmost application as string)
display dialog "An item named ?" & ¬
file_name & "? already exists in the chosen folder." & ¬
"" buttons {"Cancel", "Pick Folder", "Replace"} default button 3 with icon 2
set the chosen_action to the button returned of the result
end tell
if the chosen_action is "Replace" then
tell application "Finder"
delete item file_name of this_folder
end tell
exit repeat
end if
else
exit repeat
end if
end repeat
tell application "Finder"
set this_file to move this_file to this_folder with replacing
delete the parent_folder
-- un-comment the next line if you want to see the file in the Finder
-- reveal this_file
end tell
-- PLACE OTHER ACTIONS HERE
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
(Last edited by Sal; Feb 16, 2003 at 02:41 PM.
)
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Nov 2002
Location: US
Status:
Offline
|
|
but isn't that already what "Save as PDF..." is for? (moving a spooled PDF to a designated location)
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Apr 2001
Location: europe
Status:
Offline
|
|
Originally posted by fortepianissimo:
but isn't that already what "Save as PDF..." is for? (moving a spooled PDF to a designated location)
Yes, that's what that's for.
Sal's scripts are more like examples/templates for your own things you'd like to do. Not necessarily the simplest way to get a certain thing done.
|
|
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.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2001
Location: Santa Monica, CA
Status:
Offline
|
|
Originally posted by rytc:
I think someone mentioned this above but you need to have a valid printer setup to use this. In whatever app you're in select "Page Setup" then select "edit printer list" under the printer pull down menu. Printer App will open, then select "IP printing" and type in localhost as the printer address Ok and then it should now work for you.
That was it! Thanks, rytc.
|
|
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
Originally posted by Developer:
Yes, that's what that's for.
Sal's scripts are more like examples/templates for your own things you'd like to do. Not necessarily the simplest way to get a certain thing done.
Exactly! Thanks. You can use these scripts or parts of these scripts as beginnings for your own actions.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Feb 2003
Status:
Offline
|
|
I don't have a clue how to begin creating a directory to put into my library folder to take advantage of this new option. i have been on Apples Tech help Knowlege base site but i cannot find anything there either. Could someone give me an idea of a good instruction webpage or website on creating a directory in OS X that would help me?
Thanks for any help
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: 'round the corner
Status:
Offline
|
|
creating a directory/folder is really simple, though Apple sorta hides it. In the Finder, go to the File menu, and then to "New Folder"
rename the folder and then drag it into your library (in your home folder)
hope this is what you are asking for
|
|
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Victoria, Australia
Status:
Offline
|
|
This is great, but I'm not sure about the icons we now have for preview and PDF.
The preview one doesn't have the text "preview" on it. This is one of the annoying things with Windows - buttons that have only an image.
I can just see me trying to support this over the phone and saying to the user on the other end "Push the preview button". "What preview button?". "The one with the picture on it". ... 
|
|
|
| |
|
|
|
 |
|
 |
|
Addicted to MacNN
Join Date: Jan 2002
Location: PDX
Status:
Offline
|
|
Originally posted by curmi:
This is great, but I'm not sure about the icons we now have for preview and PDF.
The preview one doesn't have the text "preview" on it. This is one of the annoying things with Windows - buttons that have only an image.
I can just see me trying to support this over the phone and saying to the user on the other end "Push the preview button". "What preview button?". "The one with the picture on it". ...
True, but there is a popup tool tip. But none for the PDF button. Hmm..
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Feb 2003
Status:
Offline
|
|
I have placed a textedit alias in the pdf services folder, which I created in the library folder. On the print menu, the option to convert pdf to text appears. javascript :smilie('  ')
But when I select the option a garbled text document results ... javascript :smilie('  ')
How do I convert pdf to text
Soulrbl
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
Originally posted by soulrbl:
I have placed a textedit alias in the pdf services folder, which I created in the library folder. On the print menu, the option to convert pdf to text appears. javascript:smilie(' ')
But when I select the option a garbled text document results ... javascript:smilie(' ')
How do I convert pdf to text
Soulrbl
Well, you got what you asked for. You asked TextEdit to show you the text that the .pdf is made of, and there it is. It's kinda-sorta human readable, depending on your comfort level with that sort of thing.
This tool is just going to make pdf's, not convert them to text.
Now onto my question: Where in the make and email script could I put a "enter name of .pdf file" dialog, so that I don't just keep making "print job.pdf", but send people useful filenames?
Bonus question- why is this a hidden feature? There's a lot of potential here....
Sal- I took one of your Applescript classes at a MacWorld- you were a lot of fun! Thanks for sharing your knowledge on my favorite forum.
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Dedicated MacNNer
Join Date: Sep 2000
Location: Cupertino, CA USA
Status:
Offline
|
|
Originally posted by C.J. Moof:
Now onto my question: Where in the make and email script could I put a "enter name of .pdf file" dialog, so that I don't just keep making "print job.pdf", but send people useful filenames?
Bonus question- why is this a hidden feature? There's a lot of potential here....
Sal- I took one of your Applescript classes at a MacWorld- you were a lot of fun! Thanks for sharing your knowledge on my favorite forum.
You're welcome! Combining pieces of the previously posted scripts, here's a script that prompts you to name the PDF file before adding it to a new mail message;
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 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
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
Sweet! Thanks, Sal.
I took your code and made 2 changes- it automatically brings mail.app to the front, and tags on .pdf to the end so the user doesn't have to.
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 & ".pdf"
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
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2001
Location: Sitting in front of computer
Status:
Offline
|
|
So is there anyway to embed founts in the PDF document other then using distiller in classic?
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2002
Location: London, UK
Status:
Offline
|
|
Originally posted by C.J. Moof:
Sweet! Thanks, Sal.
I took your code and made 2 changes- it automatically brings mail.app to the front, and tags on .pdf to the end so the user doesn't have to.
I had a couple of problems with this script:
1. The naming process - the window where you enter the new name, if you change it from "Print job.pdf" to "name you want.pdf" it is actually renamed as "name you want.pdf.pdf" which would probably cause havoc on a windows machine.  Not a big problem now I know that it occurs, but it might be an idea to warn that .pdf will be appended on top of what is entered into the script window.
2. When inserted into the compose window in Mail, the title doesn't appear for the PDF file at all (I was able to view it by opening the inserted file in Preview).
Is this happening for you too?
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Oct 2000
Status:
Offline
|
|
I just want to know why bullets in Microsoft Word are not "printed" when I "Save to PDF..." That is UNBELIEVABLY annoying.
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Aug 2001
Location: Madison, WI
Status:
Offline
|
|
Originally posted by JKT:
I had a couple of problems with this script:
1. The naming process - the window where you enter the new name, if you change it from "Print job.pdf" to "name you want.pdf" it is actually renamed as "name you want.pdf.pdf" which would probably cause havoc on a windows machine. Not a big problem now I know that it occurs, but it might be an idea to warn that .pdf will be appended on top of what is entered into the script window.
2. When inserted into the compose window in Mail, the title doesn't appear for the PDF file at all (I was able to view it by opening the inserted file in Preview).
Is this happening for you too?
Re 1) Yes, the way I wrote it, it would blindly tag it onto the end w/o looking to see if it was needed. Since I was just using this for myself, I figure it easy enough to remember to not manually tag .pdf and let the script work for me.
It wouldn't be impossibly hard to tweak it to note the last 4 characters of the filename, and if not=".pdf" then tack it on. I'll follow up here if I get to that.
Or of course, edit the "display dialog" statement to have the appropriate warning of your choice.
2) It behaves the same for me too, and does on the simplest pdf and email script. My gut is this is a mail.app quirk, and not done b/c the script says it is supposed to.
|
|
OS X: Where software installation doesn't require wizards with shields.
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Apr 2001
Location: Victoria, Australia
Status:
Offline
|
|
Originally posted by Chaaaosss:
I just want to know why bullets in Microsoft Word are not "printed" when I "Save to PDF..." That is UNBELIEVABLY annoying.
I believe this is a bug in Microsoft's code, and there is no fix. Really annoying - we had to use Windows at work to make a PDF of a document because of this. Maybe that is exactly what Microsoft want us to do. 
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: May 2001
Status:
Offline
|
|
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.
2. When receiving the email attachment in Mail, you can't drag and drop the attachment onto the desktop. The only way to get it out of the email is with the Save Attachment menu. When I manually add the PDF as an attachment, once it is received I can drag it out as expected.
Neither of the above two are "showstoppers", but they are annoying enough for me to abandon this approach.
So, I thought I'd try to use the Applescript provided on the Apple website. I copied it into Script Editor, checked the syntax successfully, and, saved it as "Run Only". I then placed it into the "PDF Services" directory and gave it a shot. Every application I tried to "Send PDF via Mail" with crashed. I figured something must be wrong with the script itself, so brought it up in Script Editor again, but this time I saved it as a "Compiled Script". Well this approach was better, but still no cigar ...
1. After the document finished spooling, I was prompted with a dialog to name the attachment. If I got this far, I could rename it and things worked as expected. Unfortunately, whatever app I was printing from simply crashed as often as it prompted me to rename the attachment.
My verdict ....
This is a cool feature, but it's not quite ready for prime time. At least as far as the "Send PDF via Mail" is concerned.
OAW
Update: I thought I'd give the Apple supplied script another try, and lo and behold the stability doesn't seem to be a problem anymore. Well I for one won't argue with success. Unfortunately, I still periodically experience the problem described above where I can't drag and drop an attachment out of Mail that was sent via this script. Also, sometimes the PDF is attached as an icon and sometimes it's attached as a visible "inline" attachment where you can see the contents of the file. I can't figure out the rhyme and reason to either of these problems. However, it now seems to be working well enough for me to continue using this cool new feature!
OAW
(Last edited by OAW; Feb 20, 2003 at 05:06 PM.
)
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|