Printing multiple InDesign CS documents via a droplet

My main goal was printing multiple InDesign CS documents via a droplet. I still can’t believe 10.3 doesn’t support the simply command+P of yesteryear. Argghh!

InDesign CS works without a hitch. I haven’t tested out any other OS X apps in the growing list. The specific problem I have is with Quark 4.11 Classic.

I need this as an interim solution as my folks are still in the transition phase from Quark to InDesign and haven’t went full bore with InDesign. As recently as 10.2.8 (Panther broke a droplet), a user would select, for example, 10 quarks documents an drag them onto the droplet OSA Printer. It would work fine. Of course in OS 9’s Finder they could simply select and then do the ol’ command+P.

The script doesn’t seem to loop to the next document in the list. It will open open the first document in Quark, present a print dialog, I say okay, the document closes, but that’s it. It’s doesn’t proceed to open the remaining documents? I also imagine that once I do get the script to work I will need to use the ol’ paperclip-on-the-return-button trick to accept Okay for the subsequent print dialogs for each doc.

Okay, this is what I have so far:


on open listOfDocs
    set numDocs to count of listOfDocs
    repeat with theDoc in listOfDocs
        -- set currentDoc to 1
        set fileInfo to file creator of (info for theDoc)
        set Creator to default application of (info for theDoc)
        -- set fileInfo to name extension of (info for theDoc)
        -- display dialog "File " & currentDoc & " of " & numDocs & " is a " & fileInfo & ": " & name of (info for theDoc) giving up after 5
        if fileInfo = "InDn" or fileInfo = "AD65" then
            tell application "InDesign CS"
                activate
                -- open theDoc
                print theDoc without print dialog
                -- quit
            end tell
        else if fileInfo = "XPR3" then
            tell application "QuarkXPress? 4.11"
                activate
                open theDoc
                print theDoc
                -- close document theDoc
            end tell
        end if
        -- delay 4
        -- currentDoc = currentDoc + 1
    end repeat
end open

Did you create the script as a classic script, using the old script editor, or using the OS X version of script editor (1.9/2.0). From what I understand you need to make sure that the scripts controlling a classic app are running under classic to communicate properly.

That was an interesting thought as I noticed the previously working OSA Printer was a Classic applet. Saving it this way doesn’t work either. By the way, I’m using Script Debugger 3.0, a much more robust scripting tool. Mind you, Script Editor has come along from where it started.

Classic seems capable of recognizing compiled scripts from OS X, as I use them in a scripts menu with a Classic Cumulus client (5.0.10). I’m suspect of a missing routine, but I can’t put my finger on it. Thanks for the suggestion though, however it didn’t help.

Any more ideas, peoples? Again, this did work in 10.2.8, broken in 10.3.2.

First of all I cleaned up the code a bit more and changed the syntax at the beginning to identify the variable theDoc.

When I ran the script in debug mode I noticed that when if I stepped through it it would work fine. Debugging obviously allowed me to control the pace of the script as I would bring Quark back to the front to accept the print dialog, then proceed to the next step. The problem would come from running it a normal pace. What would happen is while the first document would open and present the print dialog, the script had already come back to the top of the repeat loop and consequently be waiting to run through it again. By the time I hit print, the script would have already been jammed up with a spinning Classic beachball.

What did I do you ask? I added a delay at the end of the repeat statement - a delay of 2. This delay works fine for a simple document without any images placed and the job spools off the screen in an instant. However, I will run into a problem when spooling window stays on screen for an extended period of time. I’d rather not set the delay too far out since some documents might be rather simplistic.

Is there any code that would have the script check to see if Quark was busy before continuing with the next document in the loop? It was also requested that, when hitting command+p with a whole bunch of Quark docs selected in the Finder, printing would exhibit the same behaviour as OS 9 or the OSA Printer applet. What would happen is, if the user selected a Print Style from the top of the Print Dialog in Quark, it would apply that print style to subsequent documents without presenting a print dialog each time. The syntax for that, anybody, somebody?


on open theseItems
    
    repeat with i from 1 to count of theseItems
        
        set theDoc to (item i of theseItems)
        set fileInfo to file creator of (info for theDoc)
        
        if fileInfo = "XPR3" then
            tell application "QuarkXPress? 4.11"
                activate
                print theDoc
            end tell
            
        else if fileInfo = "InDn" or fileInfo = "AD65" then
            tell application "InDesign CS"
                activate
                print theDoc without print dialog
            end tell
        else if fileInfo = "8BIM" then
            tell application "Adobe Photoshop CS"
                activate
                open theDoc
                print theDoc without Dialog
            end tell
            
        else if fileInfo = "Jpeg" then
            tell application "Preview"
                activate
                print theDoc without usingDialog
                close document theDoc
            end tell
        end if
        
        delay 2
        
    end repeat
    
end open