Platforms to show: All Mac Windows Linux Cross-Platform

/iOS/iOS Printing


Last modified Wed, 9th Apr 2024.

You find this example project in your MBS Xojo Plugin download as a Xojo project file within the examples folder: /iOS/iOS Printing

Download this example: iOS Printing.zip

Project "iOS Printing.xojo_binary_project"
Class App Inherits MobileApplication
End Class
Class MainScreen Inherits MobileScreen
Control PickPrinterButton Inherits MobileButton
ControlInstance PickPrinterButton Inherits MobileButton
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
EventHandler Sub Pressed() picker = New MyUIPrinterPickerControllerMBS picker.Present End EventHandler
End Control
Control PrintDialogButton Inherits MobileButton
ControlInstance PrintDialogButton Inherits MobileButton
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
EventHandler Sub Pressed() printController = New MyUIPrintInteractionControllerMBS Dim printinfo As New UIPrintInfoMBS printinfo.outputType = printinfo.OutputGrayscale printinfo.duplex = printinfo.DuplexLongEdge printinfo.jobName = "testing" printinfo.printerID = "Laserdrucker._ipp._tcp.local." printController.showsNumberOfCopies = True printController.printInfo = printinfo printController.printingItem = LogoImageData printController.Present End EventHandler
End Control
Control PrintDialogButton1 Inherits MobileButton
ControlInstance PrintDialogButton1 Inherits MobileButton
Constraint Constraint 1
Constraint Constraint 2
Constraint Constraint 3
Constraint Constraint 4
EventHandler Sub Pressed() printController = New MyUIPrintInteractionControllerMBS If printer = Nil Then // you can pick one by URL printer = UIPrinterMBS.printerWithURL("ipp://Laserdrucker.local.:631/ipp/print") End If Dim printinfo As New UIPrintInfoMBS printinfo.outputType = printinfo.OutputGrayscale printinfo.duplex = printinfo.DuplexLongEdge printinfo.jobName = "testing" printController.printingItem = LogoImageData printController.printInfo = printinfo Dim r As Boolean = printController.printToPrinter(printer) If Not r Then MessageBox "can't print to this printer?" End If End EventHandler
End Control
EventHandler Sub Opening() Dim logo As Picture = LogoMBS(500) Dim data As MemoryBlock = logo.ToData(Picture.Formats.PNG) LogoImageData = data End EventHandler
Property LogoImageData As MemoryBlock
Property picker As MyUIPrinterPickerControllerMBS
Property printController As MyUIPrintInteractionControllerMBS
Property Shared printer As UIPrinterMBS
End Class
Class LaunchScreen Inherits MobileScreen
End Class
Sign
End Sign
Sign
End Sign
Class MyUIPrinterPickerControllerMBS Inherits UIPrinterPickerControllerMBS
EventHandler Sub Completed(userDidSelect as Boolean, error as NSErrorMBS) System.DebugLog CurrentMethodName+" "+userDidSelect.ToString If error <> Nil Then MessageBox error.LocalizedDescription End If If userDidSelect Then Dim p As UIPrinterMBS = Me.selectedPrinter If p <> Nil Then MainScreen.printer = p MessageBox "You picked "+p.displayName+EndOfLine+p.URL End If End If End EventHandler
EventHandler Sub DidDismiss() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DidPresent() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DidSelectPrinter() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub WillDismiss() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub WillPresent() System.DebugLog CurrentMethodName End EventHandler
EventHandler Function shouldShowPrinter(printer as UIPrinterMBS) As Boolean System.DebugLog CurrentMethodName System.DebugLog "displayName: "+printer.displayName System.DebugLog "displayLocation: "+printer.displayLocation System.DebugLog "makeAndModel: "+printer.makeAndModel System.DebugLog "URL: "+printer.URL Return True End EventHandler
End Class
Class MyUIPrintInteractionControllerMBS Inherits UIPrintInteractionControllerMBS
EventHandler Sub Completed(completed as Boolean, error as NSErrorMBS) System.DebugLog CurrentMethodName+" "+completed.ToString If error <> Nil Then MessageBox error.LocalizedDescription End If Dim printInfo As UIPrintInfoMBS = Self.printInfo If printInfo <> Nil Then System.DebugLog printInfo.printerID End If End EventHandler
EventHandler Sub DidDismissPrinterOptions() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DidFinishJob() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub DidPresentPrinterOptions() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub WillDismissPrinterOptions() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub WillPresentPrinterOptions() System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub WillStartJob() System.DebugLog CurrentMethodName End EventHandler
End Class
End Project

See also:

Download this example: iOS Printing.zip

The items on this page are in the following plugins: MBS iOS Plugin.


The biggest plugin in space...