Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Print to PDF



You could use the following script attached to a folder to print some files as PDF files.
Just save a copy of your file to the folder that you attach this script to.


on adding folder items to this_folder after receiving these_items
	set this_file to choose file
	try
		tell application "Image Events"
			launch
			-- get the parent folder of the image file
			set the parent_folder to the container of this_file
			-- derive new name for the new image file
			set the new_name to my add_extension(this_file, "pdf")
			-- look for an existing file
			if (exists file new_name of the parent_folder) then
				error "A file named “" & new_name & "” already exists."
			end if
			-- open the image file
			set this_image to open this_file
			-- save in new file. The result is a file ref to the new file
			set the new_image to save this_image as PDF in ¬
				file new_name of the parent_folder with icon
			-- purge the open image data
			close this_image
		end tell
		tell application "Finder"
			-- delete the original file
			delete this_file
		end tell
	on error error_message
		display dialog error_message
	end try
end adding folder items to
on add_extension(this_file, new_extension)
	set this_info to the info for this_file
	set this_name to the name of this_info
	set this_extension to the name extension of this_info
	if this_extension is missing value then
		set the default_name to this_name
	else
		set the default_name to ¬
			text 1 thru -((length of this_extension) + 2) of this_name
	end if
	return (the default_name & "." & the new_extension)
end add_extension

Peter J Baxter
mail:  email@hidden

It's easy to play any musical instrument: all you have to do is touch the right key at the right time and the instrument will play itself.
-- J.S. Bach



_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/applescript-users/email@hidden Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Re: Print to PDF (From: "Reese, Stevan" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.