Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Using PDF Services, revisited System
This hint reminded me that PDF Services might not be getting the attention or respect they deserve. So here's a simple yet very effective tip that makes saving PDFs fun!

Create a folder on your desktop called "PDFs to Read" or create one in your Documents folder called "Online Purchases and Receipts." Now make aliases to those folders and put it them in ~/Library -> PDF Services. If the "PDF Services" folder doesn't exist, then create it first. You may also want to rename the aliases to something like "Save as PDF to read later" or "Save to Receipts folder."

Now all you have to do is select Print on a web page (or in any app, for that matter), and select the appropriate choice from the PDF Services pop-up menu, and it will save the PDF immediately to the right folder. This makes it super easy to save PDF copies of long articles to read later ... or to archive receipts of your online purchases. The resulting PDFs in these folders can, of course, be searched by their textual content in the Finder.

Thanks to 43 Folders and bbum's rants, codes and references (scroll down or search for "pdf workflow" to find the actual entry). As an aside, aliases to applications (like Mail or Entourage), or even AppleScripts can also go into PDF Services for all sorts of PDF timesaving creations. I'd love to see an AppleScript guru run with this tip and allow the PDFs name to be modified before being saved to it's destination!

[robg adds: We discussed this back in 2003, but both OS X and the PDF Services feature itself have come a long way since then. Apple's Scriptable Applications: Printing & Print Center page includes an example AppleScript that lets you set the filename before attaching it to a Mail message ... along with some other useful info on PDF Services. The ability to put AppleScripts, aliases to actual applications, aliases to folders, and even folders themselves, makes the PDF Services feature a great timesaver. The only downside, as you can see in the screenshot, is that you're stuck with icons for what used to be the Preview and Save as PDF buttons.]
    •    
  • Currently 2.80 / 5
  You rated: 3 / 5 (5 votes cast)
 
[28,078 views]  

Using PDF Services, revisited | 18 comments | Create New Account
Click here to return to the 'Using PDF Services, revisited' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Using PDF Services, revisited
Authored by: zebradung on Dec 27, '04 11:30:36AM

I knew that sooner or later features in SAFT (the recent Pick of the Week here) would be revealed as easy hints here. And this is a big one. But does anyone know how to mimic exactly what SAFT does by adding "Export as PDF" to the contextual menu in Safari? Is there a way to add a Service in general to a particular App's contextual menus?

---
-- PGP

G5 DP2.5 / 2.5GB RAM

It's so fast I get tired just watching it ...



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: Fofer on Dec 27, '04 01:11:23PM

Well, one nice thing about Saft, too, is that the PDF's it generates remain as one (sometimes LOOOONG) page. It doesn't break them up into multiple pages as the PDF Services via Print Dialog does. Which makes sense for a LOONG web page, doesn't it? Why should it be broken up into separate 11" pages, anyway? I'd like to see that as an option in the regular PDF Services via Print Dialog, too.



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: simonpie on Dec 29, '04 09:21:24PM

Any idea how to do this on purpose ? I sure would like to print my web pages as one long pdf !



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: balakera on Dec 27, '04 11:31:37AM
Expanding on the script found on this page Scriptable Applications: Printing & Print Center
I have put together this AppleScript that will prompt for the file name to create and then move it to a specified directory.
Comment in the script tell you what part to edit for your environment.

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
			(* You would need to create a directory where you want resulting PDF files saved*)
			(* and type in the full path of that directory replacing the sample on the next line *)
			move this_file to "Users:SampleUser:Sample Folder" replacing yes
		end tell
	end try
end open


[ Reply to This | # ]
Using PDF Services, revisited
Authored by: Fofer on Dec 27, '04 01:18:46PM

Submitter of the hint here. Thanks, Applescript guru, for sharing this script... that's exactly what I was hoping for! Works like a charm.

Curious if there's a way for the suggested filename to default to the name of the window we're printing though (as opposed to the generic "Print job.pdf.")

That way we could choose to leave it be if it's accurate, or edit/overwrite it with a better title. Can AppleScript handle that?



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: strikeman on Dec 27, '04 02:01:51PM
Here's a script which can prepare an attachment for Entourage, as well as fill in the name of the current window as the default name of the PDF file.
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
				set front_window_name to name of front window
				--				display dialog "Enter a name for file:" default answer file_name
				display dialog "Enter a name for file:" default answer (front_window_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 "Microsoft Entourage"
			activate
			set new_message to 
				(make new outgoing message with properties 
					{subject:"Interesting file", content:"This may be of interest", attachment:{file:target_file}})
			open new_message
		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


[ Reply to This | # ]
Using PDF Services, revisited
Authored by: Fofer on Dec 27, '04 02:17:12PM
Ah thanks for this. Using your script I was able to parse the lines I needed to combine with balakera's script, and now I am prompted to (re)name the receipt before saving. And it defaults to the name of the current web window, as opposed to "Print Job.pdf"! Okay, here goes:
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)
			set front_window_name to name of front window
			repeat
				display dialog "Enter a name for file:" default answer (front_window_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
			(* You would need to create a directory where you want resulting PDF files saved*)
			(* and type in the full path of that directory replacing the sample on the next line *)
			move this_file to "Users:username:Documents:Receipts" replacing yes
		end tell
	end try
end open
--- Now is there any way for the default name to have a .PDF suffix? That would be ideal.

[ Reply to This | # ]
Using PDF Services, revisited
Authored by: balakera on Dec 27, '04 03:08:58PM
To answer your last question - yes, it is possible to have default name to have .PDF suffix.
Here is the script:

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)
                        set front_window_name to name of front window
                        repeat
                                display dialog "Enter a name for file:" default answer (front_window_name & "." & "pdf")
                                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
                        (* You would need to create a directory where you want resulting PDF files saved*)
                        (* and type in the full path of that directory replacing the sample on the next line *)
                        move this_file to "Users:username:Documents:Receipts" replacing yes
                end tell
        end try
end open


[ Reply to This | # ]
Using PDF Services, revisited
Authored by: Jason P on Dec 29, '04 01:04:02PM

I'm total new to scripting and am copying and pasting and referencing a few docs here and there to get what I want to happen, so please take baby steps with me in any reply.

My question is how do I take the script for saving a PDF to a folder, like "Receipts", and get it to NOT overwrite another PDF of the same name? Lets say I buy a lot of things from a site whose receipt page has a front window named "item receipt", and I simply want an elegant automatic way of the file getting appended with some sort iterative suffix prior to the .pdf if there already exists a file of the exact same name? I suppose it doesn't have to be appended prior to the .pdf, but that would be good. The Finder does this when saving Safari downloads. If you duplicate a download it simply appends a number.

Thanks for any help.
Jason



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: balakera on Dec 27, '04 03:14:13PM
And for anyone who is using PowerMail here is the version that creates a new message with the PDF as an attachment:

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)
			set front_window_name to name of front window
			repeat
				display dialog "Enter a name for file:" default answer (front_window_name & "." & "pdf")
				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 "PowerMail 5.1"
			activate
			set the new_message to 
				make new message with properties {content:" "}
			make new attachment at new_message with properties {file:target_file}
			open new_message
			
		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


[ Reply to This | # ]
Using PDF Services, revisited
Authored by: u2mr2os2 on Dec 27, '04 02:25:11PM

Safari, at least, names the file with the name of the page. Not tested other apps. OS X 10.3.7, Safari 1.2.4.



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: u2mr2os2 on Dec 27, '04 02:48:02PM

To clarify, the PDF you get is named with the title of the document printed if you place an alias of a folder in your "/Library/PDF Services" or "~/Library/PDF Services" folders. Using the script given above, you get the generic "Print Job.PDF". I checked, and other apps seem to name the file with a title: Mail, TextEdit and AppleWorks. Script Editor did not.



[ Reply to This | # ]
Yet another customized script
Authored by: vgz on Dec 27, '04 03:59:38PM
Here's my modification of the example script.

This script prompts you for a name for the file (defaulting to the domain of the page you are viewing) and appends the current date and time to the filename while saving it to a specified directory.

Note: Change "Path:to:the:folder:" to the actual path to the folder you want to save in.

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 "Safari"
			set current_url to the URL of document 1
			set default_name to ""
			set current_num to 8
			repeat
				set current_character to character current_num of current_url
				if current_character is not "/" then
					set default_name to default_name & current_character
				else
					exit repeat
				end if
				set current_num to current_num + 1
			end repeat
		end tell
		tell application (path to frontmost application as string)
			repeat
				set the_date to current date
				set current_time to time string of the_date
				set safe_time to ""
				set current_num to 1
				repeat
					set current_character to character current_num of current_time
					if current_character is ":" then
						set safe_time to safe_time & "."
					else
						set safe_time to safe_time & current_character
					end if
					set current_num to current_num + 1
					if current_num > length of current_time then exit repeat
				end repeat
				set name_extension to " " & month of the_date & " " & day of the_date & ", " & year of the_date & " " & safe_time & ".pdf"
				display dialog "Enter a name for file:
(Note: '" & name_extension & "' will be appended to the end of the name.)" default answer default_name
				set this_name to the text returned of the result
				set this_name to this_name & name_extension
				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_destination to "Path:to:the:folder:" as alias
			set the target_file to 
				(document file this_name of the parent_folder) as alias
			move target_file to the_destination replacing yes
		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

---
VGZ:
Otaku, Fanfic author, and Mac Fanatic

[ Reply to This | # ]

Good script, but
Authored by: Jason P on Dec 29, '04 02:15:18PM

I'm trying to get a script that works elegantly for various applications files like excel, textedit, ...script editor, whatever, in addition to Safari. Your script as written, pulls the domain name of the active web page as the default name, but it doesn't pull the name of an active document or application window as a default name to save as. I have been fiddling with it quite a bit to get it to work, but can't seem to do it. It only likes to pull the domain name out of Safari. Would you be so kind as to give me some hints as to what to change to pull a document or application window name as the default name when trying to print to .pdf in those cases as well?

Thank you.



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: PeterDie on Dec 27, '04 05:46:01PM
Yes, but where can I find all those nice scripts Apple lists in this print dialog ? Looks like da bomb to me. PDF-wise, that is.

[ Reply to This | # ]
Using PDF Services, revisited
Authored by: DanFrakes on Dec 27, '04 11:27:42PM
Before you go to all the trouble of writing AppleScripts, check out PDF U, a free app that automatically creates the PDF Services folder and populates it with a bunch of useful AppleScripts, including:

  • Open PDF in Adobe Photoshop 7
  • Open PDF in Adobe InDesign
  • Open PDF in Adobe Illustrator
  • Open PDF in Acrobat Reader 5
  • eMail PDF with PowerMail
  • eMail PDF with Microsoft Entourage
  • eMail PDF With Mailsmith
  • eMail PDF with Mac OS X Mail
  • eMail PDF with Eudora
  • Copy PDF to Folder [which lets you name the PDF and save it to any particular folder (or create a new folder)]


[ Reply to This | # ]
Using PDF Services, revisited
Authored by: subala on Dec 28, '04 09:16:25PM

Thanks DF, this PDF U sounds like a great help. I clicked on the link and the download began without any indication of where it's from or who wrote it. Can you tell me anything about its orgin before I install and run it? Even though it's just AppleScripts, I'm the overly cautious type :)

Thanks,
Subala



[ Reply to This | # ]
Using PDF Services, revisited
Authored by: Fofer on Dec 29, '04 03:16:19AM

Just look at the URL... PDF U is from If Then Software:
http://www.ifthensoft.com/



[ Reply to This | # ]