Automate PDF Printing from FileMaker | Blog | CampSoftware

Automate PDF Printing from FileMaker

automatepdfprinting

We had the need for sometime to automatically print documents with our document management system using SuperContainer. In the past, we'd open the documents so the person using the system could print.

Yesterday, Gerard Beutler asked me about it, so I tweeted about it. With in minutes Bob Patin emailed a fantastic AppleScript where you pass a path to a file which then opens Preview, types command-P, types enter, then quits Preview. Then Fabrice Nordmann suggested using the FileMaker 'Send Event' for Windows Script Step to make it work on Windows.

With the great tips, I modified Bob's example file into the example below. I did change the AppleScript so that it didn't quit Preview, but rather close the front most window with the idea that there could be other Preview windows open and I didn't want to disrupt any other open files.

Below you can see the example file. While this example works well for PDFs, it could work with other document formats, but you should test and please add a post below with your findings! As you can see we have three PDFs, each in a container and a Print button. When you press the button, it runs the script. That's it!

Normally, we don't store documents in containers as the can quickly bloat the size of the FileMaker database. We LOVE using SuperContainer to solve that problem as the files are simply stored in a folder that SuperContainer manages. If we were to use the Print Container File solution in a production database, we would export the SuperContainer to the FileMaker Temporary folder directly or to a container and then to the FileMaker Temporary folder.

Download Print Container File

PrintContainerFile

Below you look over the script. We tried to comment it to explain each step.

Gerard found that the FileMaker 'Send Event' for Mac Script Step would also print the documents, but we found that it would not work a second time if Preview was still open. Quitting Preview after printing would work, but simply closing the front most window seemed to be the nice thing to do. Happy

PrintContainerFileScript