PDA

View Full Version : New PDF features in 10.2.4


kcmac
Feb 13, 2003, 11:11 PM
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.

greenG4
Feb 13, 2003, 11:13 PM
I think this ahs bees around a while hasn't it? Very cool though. :thumbsup:

kcmac
Feb 13, 2003, 11:16 PM
Hopefully it has been. This may mean the scripts are real. I would like to find them. :cool:

fulmer
Feb 13, 2003, 11:51 PM
"Save as PDF..." isn't new. Might have been around since 10.2, but definitely by 10.2.1 and later.

Simon Mundy
Feb 13, 2003, 11:57 PM
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!!!

gorickey
Feb 14, 2003, 12:47 AM
I want to know this as well, odd that nobody knows and Apples site isn't "more friendly"....

kcmac
Feb 14, 2003, 01:02 AM
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?

tooki
Feb 14, 2003, 01:50 AM
[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

juanvaldes
Feb 14, 2003, 01:55 AM
your other thread made 1000x more sence and this is a sweet new feature! :)

nibs
Feb 14, 2003, 03:03 AM
I want the compress PDF feature, too!!!

a) you actually need to install something like apago's pdfshrink lite (http://www.apago.com/getprodpage.cgi?prodname=PDFshrink)

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.

nibs
Feb 14, 2003, 03:11 AM
http://homepage.mac.com/nibs/.Pictures/pdfservices.jpg

PLEASE USE URL LINKS FOR LARGE IMAGES!!! - tooki

Sal
Feb 14, 2003, 03:36 AM
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)

http://www.apple.com/applescript/print/gfx/PDFWorkflow.jpg

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:



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.


#!/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"

alphasubzero949
Feb 14, 2003, 03:38 AM
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?

Sal
Feb 14, 2003, 03:41 AM
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.

alphasubzero949
Feb 14, 2003, 03:45 AM
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.

juanvaldes
Feb 14, 2003, 04:35 AM
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. :hmm:

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 :D

MasonMcD
Feb 14, 2003, 06:19 AM
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?

nibs
Feb 14, 2003, 09:07 AM
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.

pliny
Feb 14, 2003, 09:27 AM
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. :D

BobW
Feb 14, 2003, 02:22 PM
How do you get all those commands listed it the Print Window;

Compress to PDF to Send PDF via Mail

Thanks

Developer
Feb 14, 2003, 02:28 PM
Originally posted by BobW:
How do you get all those commands listed it the Print Window;

Compress to PDF to Send PDF via MailPlace 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").

nibs
Feb 14, 2003, 02:57 PM
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.

Developer
Feb 14, 2003, 03:08 PM
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. ;)

BobW
Feb 14, 2003, 03:48 PM
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

Developer
Feb 14, 2003, 04:15 PM
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.

BuonRotto
Feb 14, 2003, 08:50 PM
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.

http://homepage.mac.com/jdabrowski/.Pictures/Screenshots/PDF_Services_Folder.jpg

http://homepage.mac.com/jdabrowski/.Pictures/Screenshots/PDF_Services_Print_Dialog.jpg

brachiator
Feb 15, 2003, 01:20 AM
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!

rytc
Feb 15, 2003, 06:37 AM
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.

bfr00
Feb 15, 2003, 08:05 PM
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.

Sal
Feb 16, 2003, 02:14 AM
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!



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

darrick
Feb 16, 2003, 07:18 AM
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??

Sal
Feb 16, 2003, 10:11 AM
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.


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

fortepianissimo
Feb 16, 2003, 11:36 AM
but isn't that already what "Save as PDF..." is for? (moving a spooled PDF to a designated location)

Developer
Feb 16, 2003, 12:11 PM
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.

brachiator
Feb 16, 2003, 02:23 PM
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.

Sal
Feb 16, 2003, 03:42 PM
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.

mickelsg
Feb 16, 2003, 03:59 PM
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

Nebagakid
Feb 16, 2003, 04:06 PM
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

curmi
Feb 18, 2003, 01:14 AM
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". ... :(

::maroma::
Feb 18, 2003, 01:29 AM
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..

soulrbl
Feb 19, 2003, 04:44 AM
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(':confused:')

How do I convert pdf to text

Soulrbl

C.J. Moof
Feb 19, 2003, 12:07 PM
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(':confused:')

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.

Sal
Feb 19, 2003, 01:34 PM
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;


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

C.J. Moof
Feb 19, 2003, 03:06 PM
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.

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

Terri
Feb 19, 2003, 03:17 PM
So is there anyway to embed founts in the PDF document other then using distiller in classic?

JKT
Feb 20, 2003, 08:04 AM
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?

Chaaaosss
Feb 20, 2003, 10:44 AM
I just want to know why bullets in Microsoft Word are not "printed" when I "Save to PDF..." That is UNBELIEVABLY annoying.

C.J. Moof
Feb 20, 2003, 04:37 PM
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.

curmi
Feb 20, 2003, 05:25 PM
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. :(

OAW
Feb 20, 2003, 05:35 PM
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

C.J. Moof
Feb 20, 2003, 06: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.


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.

Sal
Feb 20, 2003, 07: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:


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
Feb 20, 2003, 08: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:


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
Feb 20, 2003, 08: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?

dmanbaby
Feb 21, 2003, 12: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
Feb 21, 2003, 01: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:


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
Feb 21, 2003, 01: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/macosx/Carbon/interapplicationcomm/AppleScript/AppleScriptLangGuide/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.


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
Feb 21, 2003, 01: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
Feb 21, 2003, 05: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
Feb 21, 2003, 01: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:


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
Feb 21, 2003, 04: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).



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
Feb 21, 2003, 04: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?

Sal
Feb 21, 2003, 04: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
Feb 21, 2003, 05: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.

cacarr1
Feb 21, 2003, 06: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.

Sal
Feb 21, 2003, 09: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/



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
Feb 22, 2003, 04: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/



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
Feb 22, 2003, 09: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
Feb 22, 2003, 02: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
Feb 23, 2003, 11:43 AM
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
Feb 23, 2003, 06: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
Feb 24, 2003, 12: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.


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
Feb 24, 2003, 12: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.
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
Feb 24, 2003, 12: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.

Sal
Feb 24, 2003, 01: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.


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
Feb 24, 2003, 03: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
Feb 24, 2003, 03: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
Feb 24, 2003, 05: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
Feb 24, 2003, 06: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
Feb 25, 2003, 11:07 PM
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
:p

BuonRotto
Mar 4, 2003, 09: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
Feb 27, 2004, 02: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
Feb 27, 2004, 06: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