Printing TIFFs as PDFs
Printing TIFFs as PDFs
- Subject: Printing TIFFs as PDFs
- From: Hugo Benitez <email@hidden>
- Date: Sun, 15 Jun 2003 11:31:42 -0500
Hi,
I understand that Preview is not scriptable, by using the following
script, which needs the new System Events application (The December
2002 Developer Tools release contains a beta version of the System
Events application with support for controlling the GUI of applications
with scripts):
This script is provided by the System Events beta version, slightly
modified to meet Steve4s requirements:
property type_list : {"TIFF", "JPEG", "PICT", "GIFf"}
property extension_list : {"tif", "tiff", ",jpg", ",jpeg", "pic",
"pict", "gif", "giff"}
global destination_path
on run
display dialog "Export TIFF/JPEG/PICT/GIF to PDF" & return & return & ,
"Drag TIFF/JPEG/PICT/GIF images onto this droplet to export PDF
copies of them from the Preview application." buttons {"Done"} default
button 1
end run
-- This droplet processes files dropped onto the applet
on open these_items
set the image_list to {}
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
set the item_info to info for this_item
if (folder of the item_info is false) and ,
(alias of the item_info is false) and ,
((the file type of the item_info is in the type_list) or ,
the name extension of the item_info is in the extension_list) then
set the end of the image_list to this_item
end if
end repeat
if the image_list is {} then
display dialog "The dragged-on items contained no proper images."
buttons {"Cancel"} default button 1
end if
-- prompt the user for a new destination folder
set the destination_path to ,
(choose file name with prompt "Enter the name and location for a new
destination folder:" default name "Exported Images") as string
set AppleScript's text item delimiters to ":"
set the parent_folder to ((text items 1 thru -2 of the
destination_path) as string) & ":"
set the destination_foldername to the last text item of the
destination_path
set AppleScript's text item delimiters to ""
tell application "Finder"
set the destination_folder to (make new folder at folder
parent_folder with properties {name:destination_foldername}) as alias
end tell
-- convert the folder reference to a POSIX path
set the destination_path to the POSIX path of destination_folder
-- process the images
repeat with i from 1 to the count of image_list
set this_item to item i of the image_list
process_item(this_item)
end repeat
end open
-- this sub-routine processes files
on process_item(this_item)
try
-- NOTE that the variable this_item is a file refernce in alias format
-- FILE PROCESSING STATEMENTS GOES HERE
tell application "Preview"
activate
open this_item
end tell
delay 2
tell application "System Events"
tell process "Preview"
click menu item "Export" of menu "File" of menu bar 1
delay 1
tell sheet 1 of window 1
tell pop up button 1
click
delay 1
tell menu 1
set the menu_options to the name of every menu item
if the menu_options contains "PDF" then
click menu item "PDF"
delay 1
else
error "Cannot convert this image to PDF format."
end if
end tell
end tell
end tell
tell window 1
tell sheet 1
tell group 2
tell group 1
tell text field 1
set the new_imagename to the value
set the value to the destination_path & new_imagename
delay 1
end tell
end tell
end tell
end tell
end tell
keystroke return
delay 2
keystroke "w" with command down
end tell
end tell
on error the error_message number the error_number
display dialog the error_message buttons {"Cancel"} default button 1
end try
end process_item
Hope is useful.
Regards,
Hugo
>
Date: Thu, 12 Jun 2003 11:56:38 -0500
>
Subject: Printing TIFFs as PDFs
>
From: Stephen Holland <email@hidden>
>
To: email@hidden
>
>
I have TIFF's that open in Preview that I want to convert to PDF's. I
>
am opening them in Preview and doing a print selecting the Print as PDF
>
button that OS X gives us. I don't find the dictionary for Preview,
>
and the finder dictionary doesn't help me either.
>
>
Anyone know how to script this?
>
>
Steve Holland
MAIL ESCANEADO UTILIZANDO LA ALTA TECNOLOGIA DE ANDINANET Y MCAFEE
MAIL ESCANEADO UTILIZANDO LA ALTA TECNOLOGIA DE ANDINANET Y MCAFEE
_______________________________________________
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.