3 Replies Latest reply on May 14, 2018 7:42 AM by jocstone_me

    Call the Finder print window from within Indesign

    jocstone_me Level 1

      Hi,

       

      I have a few Applescripts to automate all of my print jobs.

       

      Since we us a new pinter in the office, the machine uses a authentication.

      That authentication is just a number provided in a submenu of the Finders Print window.

      When printing manually, in the Indesign print window, we have to click the "printer" window first, click ok and then print, just to activate the authentication.

      However, when I print from Indesign using a script, that print screen is ignored, so, the authentication code is also ignored.

      Is there a way to call that Finder print window (and close it again) prior to the Indesign print command?

       

      I hope my explanation is clear to understand :-)

      Any help or suggestions are welcome.

       

      Thanks!

      Schermafbeelding 2018-05-07 om 13.22.03.png

       

      Here's one example of one of my scripts (all credits go to MacGrunt for this)

      on returnNumbersInString(inputString)
        set s to quoted form of inputString
        do shell script "sed s/[a-zA-Z\\']//g <<< " & s
        set dx to the result
        set numlist to {}
        repeat with i from 1 to count of words in dx
        set this_item to word i of dx
        try
        set this_item to this_item as number
        set the end of numlist to this_item
        end try
        end repeat
        return numlist
      end returnNumbersInString
      
      
      tell application id "com.adobe.InDesign"
        tell document preferences of active document
        set myBleedText to document bleed top offset as string
        end tell
      end tell
      
      
      set myBleed to returnNumbersInString(myBleedText)
      
      
      tell application id "com.adobe.InDesign"
        tell active document
        set theLinks to every link
        repeat with aLink in theLinks
        if status of aLink is link out of date then
        -- update aLink
        display dialog "Er zijn gewijzigde beelden aanwezig in het document, ben je zeker dat je wil verder gaan?"
        else
        if status of aLink is link missing then -- other options are normal/link out of date/link missing/link embedded
        --missing link handling
        display dialog "Er zijn ontbrekende beelden aanwezig in het document, ben je zeker dat je wil verder gaan?"
        end if
        end if
        end repeat
      
        set mgPgFace to facing pages of document preferences as string
        set mgPgOrnt to page orientation of document preferences as string
        set mgDocHght to page height of document preferences
        set mgDocWdth to page width of document preferences
        set mgDocHght to mgDocHght as integer
        set mgDocWdth to mgDocWdth as integer
        set the page range of print preferences to all pages
        set mgPgHght to mgDocHght + myBleed + myBleed + 10
        set mgPgWdth to mgDocWdth + myBleed + myBleed + 10
      
        if mgPgFace is "true" then --print document as spreads
        if mgPgHght is greater than 185 or mgPgWdth is greater than 130 then --use one of the A4 presets
        if mgPgHght is greater than 277 or mgPgWdth is greater than 200 then --use A3 fit preset
        set mgPrintPreset to "A3 comp liggend spread fit"
        else --use A3 100% preset
        set mgPrintPreset to "A3 comp liggend spread"
        end if
        else --use A4 horizontal preset
        set mgPrintPreset to "A4 comp liggend spread"
        end if
      
        else --print document as single pages
        if mgPgOrnt is "portrait" then --use one of the vertical presets
        if mgPgHght is greater than 277 or mgPgWdth is greater than 200 then --use one of the A3 presets
        if mgPgHght is greater than 400 or mgPgWdth is greater than 277 then --use A3 fit preset
        set mgPrintPreset to "A3 comp staand spread fit"
        else --use A3 100% preset
        set mgPrintPreset to "A3 comp staand spread"
        end if
        else --use A4 vertical preset
        set mgPrintPreset to "A4 comp staand spread"
        end if
      
        else --use one of the horizontal presets
        if mgPgHght is greater than 200 or mgPgWdth is greater than 277 then --use one of the A3 presets
        if mgPgHght is greater than 277 or mgPgWdth is greater than 400 then --use A3 fit preset
        set mgPrintPreset to "A3 comp liggend spread fit"
        else --use A3 100% preset
        set mgPrintPreset to "A3 comp liggend spread"
        end if
        else --use A4 horizontal preset
        set mgPrintPreset to "A4 comp liggend spread"
        end if
      
        end if
        end if
      
        print using (mgPrintPreset as string) without print dialog
        if modified is true then save
        display notification "Uw document wordt geprint" with title mgPrintPreset
        end tell
      end tell
      
      
      print using (mgPrintPreset as string) without print dialog
      
      
      if modified is true then save
      
      
      display notification "Uw document wordt geprint" with title mgPrintPreset
      
      end tell
      
      end tell
      
        • 1. Re: Call the Finder print window from within Indesign
          jocstone_me Level 1

          Since it seems hard to find any solution I put only the most important piece of the scripts here:

          print using (mgPrintPreset as string) without print dialog

           

          I can change this to:

          print using (mgPrintPreset as string) with print dialog

          delay 0.5

          repeat 12 times

          key code 48

          delay 0.5

          end repeat

          keystroke space

          delay 0.5

          keystroke return

           

          Then I tried to call a system event to "tab" x times so the Printer button comes active, "space" to go there and so on.

          However, I cannot run this system event while the Indesign pint dialog is active. When that dialog closes, then runs the system events, too late of course…

          • 2. Re: Call the Finder print window from within Indesign
            Trevorׅ Adobe Community Professional

            You basically have to prevent the default print action on clicking InDesigns print ok button so that it just closes the print dialog and then runs some applescript to call on Finder and then print the ID document with jsx (or applescript) with out reopening the print dialog.

            If you know what you are doing it's simple, if you don't then it's not

            • 3. Re: Call the Finder print window from within Indesign
              jocstone_me Level 1

              That is exactly what I intend to do…

              My problem is that I am not an expert at all, I cut, past and adjust most of the script I use.

              Maybe it is possible to call the system print dialog prior to the Indesign printing dialog?

              I don't know if that even makes any sense…