Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Recommended Posts

Posted

iOSPickPrinter.png

If you use FileMaker iOS SDK, we can provide a few new print commands for iOS in the MBS FileMaker Plugin in version 14.2. The new PDFKit.SelectPrinter function allows you to pick a printer. And the PDFKit.Print function got extended to print PDF documents as well as images. You can configure printing with PDFKit.SetPrintSetting function.

 

Let's start with selecting a printer:

 

If [ Length ( PDFKit Print::PrinterURL ) > 0 ]

   Set Variable [ $r ; Value: MBS( "PDFKit.SetPrintSetting"; "PrinterURL"; PDFKit Print::PrinterURL ) ]

End If

# show the dialog

Set Variable [ $userDidSelect ; Value: MBS( "PDFKit.SelectPrinter" ) ]

If [ MBS("IsError") ]

   Show Custom Dialog [ "Failed to show printer selecto…" ; $r ]

Else If [ $userDidSelect ]

   # and check what we got

   Set Variable [ $printerURL ; Value: MBS( "PDFKit.GetPrintSetting"; "PrinterURL" ) ]

End If

 

This shows the printer picker dialog on iOS and we can pick a printer. If you had selected a printer before, the plugin would remember it. But if you had one stored in a field in the database, you may pre-select that one. After the user picked something, we store the prints in a variable/field.

 

To print, we need something to print. That may be a container with an image or PDF document. Or you have a file on disk which could be an image or PDF file again. If you have a PDF document in memory through PDFKit.NewPDFDocument, PDFKit.OpenContainer, PDFKit.OpenPath or PDFKit.OpenURL, you can also pass the reference number. This way you could assemble a PDF in memory and print it directly without storing it in a temporary file or a container field.

 

# Print

Set Variable [ $r ; Value: MBS("PDFKit.Print"; PDFKit Print::PrintItem) ]

If [ MBS("IsError") ]

   Set Field [ PDFKit Print::Result PDFKit Print::Result ; $r $r ]

   Show Custom Dialog [ "Failed to open file" ; $r ]

Else

   Set Field [ PDFKit Print::Result PDFKit Print::Result ; $r $r ]

End If

 

The printing can happen with or without dialog. If you skip the dialog using PDFKit.SetPrintSetting and the ShowsPrintPanel option being zero, you need to tell the plugin where to print to. For that, please pass the printer URL to the PDFKit.SetPrintSettingfunction for PrinterURL option.

 

The following script prints something from the container directly to the printer named LaserDrucker:

 

Set Variable [ $r ; Value: MBS( "PDFKit.SetPrintSetting"; "ShowsPrintPanel"; 0 ) ]

Set Variable [ $r ; Value: MBS( "PDFKit.SetPrintSetting"; "PrinterURL"; "ipp://Laserdrucker.local.:631/ipp/print" ) ]

Set Variable [ $r ; Value: MBS( "PDFKit.SetPrintSetting"; "OutputType"; "Grayscale" ) ]

Set Variable [ $r ; Value: MBS( "PDFKit.SetPrintSetting"; "JobTitle"; "Test" ) ]

Set Variable [ $r ; Value: MBS( "PDFKit.SetPrintSetting"; "DuplexMode"; "LongEdge" ) ]

# show the dialog

Set Variable [ $r ; Value: MBS("PDFKit.Print"; PDFKit Print::FileContainer) ]

If [ MBS("IsError") ]

   Set Field [ PDFKit Print::Result PDFKit Print::Result ; $r $r ]

   Show Custom Dialog [ "Failed to open file" ; $r ]

Else

   Set Field [ PDFKit Print::Result PDFKit Print::Result ; $r $r ]

End If

 

As you see the printer URL includes the ipp prefix, the port number. To learn the printer URL, you can use the picker dialog above.

iOSPrint1.png iOSPrint2.png

Please try the 14.2 plugin and see if this works for you. Please don't hesitate to contact us with your questions.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.