I have an applescript droplet that creates a pdf file, opens that pdf file in Acrobat and brings up a dialog box asking whether the pdf file looks ready to print. If I click yes, the script moves the file to the printer’s hot folder and begins printing it. The script is working and moving the file to the hot folder, but when it does that, it also throws up an error message saying the “handler can’t handle objects of this class”. I am new to applescript. What do I need to change so I stop seeing that error message?
I tried coercing the variable pdfFile as a file instead of an alias, but then it doesn’t send it to the hot folder at all whereas as an alias it sends it and then gives me the error message.
on open droppedfile
---------------------------------------------------------------------
--PART #1 - GETTING THE FILE NAME AND PATH AND CREATING PDF FILE
set my_destination to "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:3_Signs:*PDFs to Print:" as string
tell application "Adobe InDesign CC 2014" to activate
repeat with afile in droppedfile
--GETTING RID OF INTERRUPTING MISSING FONT & IMAGE DIALOG BOXES
tell application "Adobe InDesign CC 2014"
set user interaction level of script preferences to never interact
--OPENING THE FILE IN INDESIGN
open afile
--DECLARING VARIABLES FOR THE PATH TO THE DOCUMENT
set doc_name to get name of active document as string
set pdf_name to text 1 thru -6 of doc_name as string
set final_pdf_name to pdf_name & "_bleed" & ".pdf"
set pdf_destination to my_destination & final_pdf_name
tell PDF export preferences
set view PDF to true
end tell
--TELLING IN DESIGN TO CREATE PDF FILE
tell document 1
--change PDF Preset name from "IDPDF_Bleed" to your pdf preset
export format PDF type to pdf_destination using "IDPDF_Bleed" without showing options
close afile saving no
--RESETTING USER INTERACTION SO DIALOG BOXES COME UP AGAIN
tell application "Adobe InDesign CC 2014"
set user interaction level of script preferences to interact with all
end tell
end tell
end tell
---------------------------------------------------------------------
---------------------------------------------------------------------
--PART #2 - CHECKING THE PDF IN ADOBE ACROBAT. IF FILE IS OK, MOVING THE FILE TO THE PRINTER'S HOT FOLDER
tell application "Adobe Acrobat Pro"
activate
set default zoom type to fit page
tell application "Finder"
set pdfFile to pdf_destination as alias
activate
close Finder windows
display dialog "Does this file look ready to print and is the printing profile set to the right one?" buttons {"Yes! Print Me!", "No. Close Me."}
if result = {button returned:"Yes! Print Me!"} then
duplicate file pdfFile to alias "Volumes:server1:Advertising Department:5_ADVERTISING DEPT - PREPRESS:Epson Hot Folder:"
close
else if result = {button returned:"No. Close Me."} then
display dialog "Ok. The file has been closed. Please correct the InDesign file and drop it on the droplet again."
close
end if
end tell
end tell
---------------------------------------------------------------------
end repeat
end open