AnsweredAssumed Answered

Embed Applescript in Global Field to (Export Container and Trigger Printing with Acrobat)

Question asked by AnthonyTesoriero on Jun 24, 2014
Latest reply on Jun 25, 2014 by AnthonyTesoriero

Title

Embed Applescript in Global Field to (Export Container and Trigger Printing with Acrobat)

Post

     I am trying to tie together a filemaker script that will export PDFs to a temporary space and use and apple script to print them.

     I was able to cull together info from this and some other boards to create an applescript that will print the PDFs using Acrobat from a folder.

     I have already created a script that finds the Related attachments and exports them to the desktop.

     What I'm having trouble with is merging the two.

     I need to export the PDF to a folder or temporary place and trigger the apple script to initiate the printing...

     I read this suggestion on another board but can't figure out how to implement...

         
  •           Calculate the location to export by appending the filename to Get( TemporaryPath ).
  •      
  •           Export the container field contents to FileMaker to that path.
  •      
  •           Save the path to a global field in FileMaker
  •      
  •           Use an embedded AppleScript to access the global field path
  •      
  •           Use AppleScript to open the file in Preview and print it
  •      
  •            

      

     My FM Scripting is attached in an image:

      

     This is my apple script: 

      

set myFolder to (path to desktop folder as text) & "Print:"

set myfiles to list folder myFolder without invisibles

repeat with myfile in myfiles

set mycurrentfile to ((myFolder as string) & (myfile as string)) as string

     batchprint(mycurrentfile)

end repeat

on batchprint(mycurrentfile)

tell application "Adobe Acrobat Pro"

activate -- bring up acrobat

open alias mycurrentfile -- acrobat opens that new file    

tell application "System Events"

tell process "Acrobat"

click menu item "Print..." of menu 1 of menu bar item "File" of menu bar 1

click button "Print" of window "Print"

tell application "System Events"

tell process "Acrobat"

click menu item "Close" of menu 1 of menu bar item "File" of menu bar 1

end tell

end tell

end tell

end tell

end tell

      

tell application "Finder" -- to move the printed file out 

set x to ((path to desktop folder as text) & "Printed PDFs:")

if alias x exists then

beep

else

make new folder at the desktop with properties {name:"Printed PDFs"}

end if

move alias mycurrentfile to folder "Printed PDFs"

end tell

end batchprint

         
  •            

FM.png

Outcomes