Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Printer.Print
Prints a document with options.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Printer | 6.5 | ❌ No | ✅ Yes | ❌ No | ❌ No | ❌ No |
Parameters
Parameter | Description | Example | Flags |
---|---|---|---|
Printer | The printer name to set. Must not match exactly, just the first letters. If empty, we use current. |
"Brother" | |
CloseDialog | Whether to close print dialog. 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. |
1 | Optional |
Number of Copies | The number of copies. Leave empty to not change. |
1 | Optional |
Paper Format | The name of the paper format. Leave empty to not change. |
"A4" | Optional |
Paper Orientation | The paper orientation. Pass portrait or landscape. Empty value leaves setting as is. |
"landscape" | Optional |
Paper Source | The paper source. Pass name of setting. Name doesn't need to match exactly, just first letters. So you can pass "Man" für Manual (English) and Manuell (German). |
"Man" | Optional |
Pages From | The start number of page range. Pass empty text for Pages From and To to select all pages. |
1 | Optional |
Pages To | The end number of page range. Pass empty text for Pages From and To to select all pages. |
1 | Optional |
Collate Pages | Whether to collate pages. Pass 1 to enable or 0 to disable. Other values are ignored, so pass -1 or empty value to leave existing value. |
1 | Optional |
What | What to print: Pass 0 for records being browsed. Pass 1 for current record. Pass 2 for Blank Record showing fields. Default is empty (or -1) to keep current setting. |
0 | Optional |
PrintToFile | Available in MBS FileMaker Plugin 12.1 or newer. Whether to print to file. Pass 1 to enable or 0 to disable. Other values are ignored, so pass -1 or empty value to leave existing value. |
Optional |
Result
Returns OK or error.
Description
Prints a document with options.The plugin will show the print dialog from FileMaker, automatically set options and close dialog if requested. Sub dialog for paper is opened if paper format, paper orientation or source is passed.
The function returns before the dialog shows, so please do a script pause after calling this.
This function requires the permissions for current user to print and the print menu commands be available via menu as we trigger those to print.
You can later call Print.ErrorLog to detect errors. If Windows ever change dialogs, features may no longer work. FileMaker may not show the print dialog if there is no record available or when debugger is open.
For Mac, please check PrintDialog.Install function.
To print on a server, you can create a PDF document and send it to printer via DynaPDF.Print or PDFKit.Print functions.
After calling this method, you can call Printer.PaperFormats, Printer.PaperSources or Printer.PrinterNames to learn what was available.
Version 9.1 or newer allows you to pass 3 for CloseDialog parameter to leave dialog open while sub dialog is closed.
Original source code sponsored by schubec.com
http://www.schubec.com
Examples
Print:
Set Variable [$r; Value:MBS("Printer.Print"; Printer Dialog::Printer Name; Printer Dialog::Close Dialog; Printer Dialog::Number of Copies; Printer Dialog::Paper Format; Printer Dialog::Paper Orientation; Printer Dialog::Paper Source; Printer Dialog:…]
Pause/Resume Script [Duration (seconds): 2]
Show Custom Dialog ["Result"; MBS("Printer.ErrorLog")]
Install special print menu with print command:
# set a menu with print commands, so the print works
Install Menu Set [ “[Print]” ; Use as file default: Off ]
# now let the plugin print
Set Variable [ MBS ("printer.print") ]
# wait
Pause/Resume Script [Duration (seconds): 2]
# and restore custom menus
Install Menu Set [ “[Standard Menu]” ; Use as file default: On ]
See also
- PageSetupDialog.Install
- PrintDialog.Install
- Printer.CurrentNumberOfCopies
- Printer.CurrentPaperFormat
- Printer.CurrentPaperSource
- Printer.CurrentPrintWhat
- Printer.ErrorLog
- Printer.PrinterInfo
- Printer.PrinterNames
- Printer.SetDefaultPrinter
Release notes
- Version 14.0
- Fixed window functions for future FileMaker version, e.g. affect Printer.Print.
- Version 12.1
- Added PrintToFile parameter to Printer.Print function.
- Version 10.2
- Fixed bug with Printer.PrinterInfo function returning value for NSDeviceIsPrinter parameter.
- Version 9.2
- Added 20ms pause after setting copies in Printer.Print to let dialog notice the change.
- Changed Printer.Print to only set collatePages is 0 or 1 and ignore parameter otherwise.
- Version 9.1
- Added CloseDialog = 3 mode for Printer.Print to keep main dialog open, but close sub dialog.
- Fixed problem with Printer.Print picking items in popup menu if you have two similar starting entries.
- Version 9.0
- Changed Printer.Print to prefer selecting exact match over beginning of text.
- Improved out of bounds error message for Menu.InsertItem, Menu.RemoveItemAtIndex, Calendar.Item.GetAttendeeURL, Calendar.Item.GetAttendeeCommonName, Calendar.Item.GetAttendeeStatus, Printer.PrinterName and CLGeocoder.PlacemarkValue.
- Version 7.1
- Changed Printer.Print to make printer name optional.
Example Databases
- Win Only/Printer Switch/Printer Dialog
- Win Only/Printer Switch/PrinterToolWin/printerTool_FM15
- Win Only/Printer Switch/Query Paper Formats and Sources
Blog Entries
- MBS @ FMTraining.TV - Printing in FileMaker with the MonkeyBread Plug-in
- MBS FileMaker Plugin, version 13.6pr3
- Control printing in FileMaker with MBS Plugin on Windows
- MBS FileMaker Plugin, version 12.1pr4
- MBS FileMaker Plugin, version 9.2pr1
- MBS FileMaker Plugin, version 9.1pr5
- MBS FileMaker Plugin, version 9.1pr1
- MBS FileMaker Plugin, version 9.0pr8
- MBS FileMaker Plugin, version 7.1pr2
- Printer Switch for Windows with MBS FileMaker Plugin
FileMaker Magazin
This function is free to use.
Created 14th November 2016, last changed 10th June 2023