Re: PDF Services - I'm lost...
Re: PDF Services - I'm lost...
- Subject: Re: PDF Services - I'm lost...
- From: Michael Cytrynowicz <email@hidden>
- Date: Wed, 13 Aug 2003 02:40:28 +0200
Hi Matthew,
I thought about naming the pdf files myself - but as it happens
Safari is pretty smart when naming them itself. I have 100s of pdfs
generated this way (printing to folder aliases) and have been pretty
happy with the file names. Apple did a good job. BTW, Mozilla or
others don't create nice PDF workflow file names. If I remember well,
Mozilla will do a "Mozilla 1" "Mozilla 2", whatever. Useless.
So, the thing was to actually "capture" these names that Safari aptly
gets from the html page titles, so I could paste them, say, into
NoteTaker, or OmniOutliner, or FileMaker, and have a neat register of
what I am pdf printing, and to which folders in my HDs.
Did you have a chance to look at the later code I wrote - It worked
for a while but then for some mysterious reason it works no more. I
am assuming (based on what you taught me, plus Apple's site) that
something invisible to me (could it be Printing Services?) handles
the list, then I tell Finder, tell Safari (to get the window title),
and tell Finder again in order to delete the copy of the pdf spooled
to the tmp folder. As I mentioned, it was working (other than leaving
a .ds file behind, but thats another problem).
here's my code - what am I doing wrong?
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
-- up to here, all is fine
tell application "Safari"
set the xfile_name to the name of front window as Unicode text
set the clipboard to xfile_name
--works OK
set filename_length to the length of xfile_name
if filename_length > 255 then beep
--but it never did
end tell
tell application "Finder"
set the name of this_file to (xfile_name & ".pdf")
set the clipboard to the name of file this_file as text
set targetfolder to choose folder
duplicate this_file to targetfolder without replacing
delete folder parent_folder
end tell
-- worked OK, saved the pdf to the folder I chose
--I would then expand the script to choose a folder from a list
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
-- this also worked OK, except for a .ds left behind
end if
end try
end open
------
Cheers,
Mike
>
The PDF service is given a file with the name "Print job.pdf". It won't give
>
you anything else. You could ask Safari for the title of the frontmost
>
window. Won't it be the window being printed? You would somehow have to know
>
that you were printing from Safari, as the PDF service could be used from
>
any application.
>
>
What I would normally do is ask the user to give the file a better name
>
using "display dialog".
>
>
on open these_items
>
set this_file to item 1 of these_items
>
tell application "Finder"
>
set the file_name to the name of this_file
>
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
>
end tell
>
...
>
end open
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.