« EPS support deprecate… | Home | Control printing in F… »

Control printing in FileMaker with MBS Plugin on MacOS

You may want to use our plugin functions to control printing in FileMaker Pro. Built-in to FileMaker is a script step, which allows you to configure printer settings with a dialog and store them in the script. But that is specific to the selected printer and may not work with a different one.

For a bigger solution, you may want to have a table with details for printers, so you can pick the right printer based on what you like to print. For example use a black & white laser printer for some prints, but use a color printer for some reports and print invoices on a printer with some specific later paper in one tray for the first page. And then print other pages of the invoice with different paper.

Let's start and check the PrinterDialog functions for macOS. Please understand that the plugin patches printer functions in FileMaker to put the plugin between FileMaker Pro and macOS. FileMaker triggers the print dialog and our plugin intercepts this to either show the dialog or just sets the values. To install the patch, you use our PrintDialog.Install function. This one is called once before you use other printer functions,

In a script you enable it before printing and then disable it later. In-between you have the FileMaker print script step with dialog enabled. Our plugin intercepts the dialog and after the call, you call PrintDialog.GetLastSettings to query the settings. Here is the sample script:

Set Variable [ $r ; Value: MBS("PrintDialog.Enable") ]
Print [ With dialog: On ]
Set Variable [ $r ; Value: MBS("PrintDialog.Disable") ]
Set Variable [ $r ; Value: MBS("PrintDialog.GetLastSettings") ]
Set Field [ Printer Dialog::LastSettings ; $r ]


Now you can run this script and print out with various options like the different trays on the printer. Inside the last settings, you find e.g. the name for the tray used with the key InputSlot. Of course you may just cancel the print jobs before the printer actually prints them.

For my printer, I learn that the tray name shows with the key InputSlot and the name "tray-1". Other printers name the trays e.g. Tray1, Tray2, Left, Right, Lower, Middle, Upper or whatever the printer manufacturer decided. Alternatively you can find the tray names in the ppd file for the printer.

Now you can automate your print job by using the plugin. For example you may pick a certain printer, enable duplex, set the tray, request to print current record only and don't show the dialog:

Set Variable [ $r ; Value: MBS("PrintDialog.Enable") ]
Set Variable [ $r ; Value: MBS( "PrintDialog.SetNoDialog"; 1 ) ]
Set Variable [ $r ; Value: MBS( "PrintDialog.SetCopies"; 1 ) ]
Set Variable [ $r ; Value: MBS( "PrintDialog.SetDuplex"; 1 ) ]
Set Variable [ $r ; Value: MBS( "PrintDialog.SetTray"; "tray-1" ) ]
Set Variable [ $r ; Value: MBS( "PrintDialog.SetPrintType"; 1 ) ]
Set Variable [ $r ; Value: MBS( "PrintDialog.SetPrinterName"; "MyLaserPrinter" ) ]
Print [ With dialog: On ]
Set Variable [ $r ; Value: MBS("PrintDialog.Disable") ]


Some special options can be found in the print dialog and then seen in the text from PrintDialog.GetLastSettings. For example we may find a key OutputBin and a value MailBoxBin7 for the output bin. You can set this via the PrintDialog.SetOption option:

Set Variable [ $r ; Value: MBS("PrintDialog.SetOption"; "OutputBin"; "MailBoxBin7") ]

If you like to know the list of printers, you can use Printer.PrinterCount function. Then loop over the indexes from 0 to count-1 and query Printer.PrinterName function.

Beside printing this way, you can also use our PageSetupDialog functions to change the paper size for the current layout. Then FileMaker will use that paper size for both PDF export and printing.

Let us know if you have questions. For Windows, please read Control printing in FileMaker with MBS Plugin on Windows Claris FileMaker Plugin
11 06 23 - 09:36