« Control printing in F… | Home | MBS FileMaker Plugin,… »

Control printing in FileMaker with MBS Plugin on Windows

After you read the blog post about printing on macOS, you may wonder how to use these functions on Windows. The answer is that we have different Printer functions. On Windows we show the standard print dialog and click for you since we can't intercept it like we do on macOS. But this is usually quick enough, that you may only see the dialog for half a second.

The Printer.Print function goes like this:

MBS( "Printer.Print"; Printer { ; CloseDialog; Number of Copies; Paper Format; Paper Orientation; Paper Source; Pages From; Pages To; Collate Pages; What; PrintToFile } )

Over time we added quite a few parameters. First one is the name of the printer. Since the match prefers first a complete match and alternative the first left characters need to match. Passing "HP" will pick the first HP printer. After the dialog closed, you can query Printer.PrinterNames function to ask what printer names our plug-in saw in the dialog.

The CloseDialog parameter is to decide how to close the dialog and we have four options:
Pass 0 to leave dialog open.
Pass 1 to close by pressing OK.
Pass 2 to press cancel button in case you just want to learn the options.
Pass 3 to leave dialog open, but close sub dialog.

If you just want to learn what options are available, you use 2 for CloseDialog, so the plugin cancels the dialog, but reads out the options using Printer.PaperFormats. Printer.PaperSources and Printer.PrinterNames functions. Otherwise you would pass 1 to actually print.

Next you can provide the number of copies to print. If this options is empty, the copies field is not changed. Same for paper format, where you can pick something from the menu or leave it blank. With paper orientation you can pass empty text, "landscape" or "portrait". The paper source again can be picked from a list and either be empty or the name you like to use.

If you only want to print selected pages, you can pass in a range in the next two parameters. But if you leave them empty, the whole document will be printed. The collate options defines how pages get sorted in printing. Pass 1 to turn on collate, pass 0 to disable and empty value to not touch it.

The what parameter defines what to print. This is a set of radio buttons from FileMaker, where you can pick 0 for current records being browsed, 1 for current record or 2 for a blank record showing the fields Or again an empty value to keep existing value.

We have an additional PrintToFile option, which can be checked. If set to 1, the print will go to a file on disk. That usually is used with the PDF printer and shows a save dialog. But there is the possibility to configure the printer to always put the PDF file in a fixed space, so your FileMaker script can pick it up later.

Now to run the print command, make sure you have the menu set with print command. A custom menu set may not have the required command. Next you need to have a pause script step after the MBS call, so the dialog can show. The whole click through may take a second:

Set Variable [$r; Value:MBS("Printer.Print"; $PrinterName; 1 ) ]
Pause/Resume Script [Duration (seconds): 2]
Show Custom Dialog ["Result"; MBS("Printer.ErrorLog")]

After printing worked, you can check Printer.ErrorLog function for whether it has any error message.

If you like to change paper format for the next print or PDF export, you can use Printer.SetPrinter function to pick a printer and paper format.

Let us know if you have questions. Claris FileMaker Plugin
12 06 23 - 07:20