Forum Xamarin.iOS

How to print to a bluetooth thermal printer?

xdev16xdev16 USMember ✭✭

My Xamarin forms app needs to print labels to a thermal printer (Brother QL 820 NW). I am creating a label in webview and then printing it. I am able to print the labels over wifi using the code below.
Now, I want to print the using bluetooth. The printer is already paired with the iOS device. How can I achieve this? Thanks!

            string printerIP = "";
            var printInfo = UIPrintInfo.PrintInfo;
            printInfo.OutputType = UIPrintInfoOutputType.General;
            printInfo.JobName = "My label Print";
            printInfo.Orientation = UIPrintInfoOrientation.Landscape;
            printInfo.Duplex = UIPrintInfoDuplex.None;

            var printController = UIPrintInteractionController.SharedPrintController;
            var url = NSUrl.FromString (@"http://" + printerIP + ":631/ipp/print");
            var printerObj = UIPrinter.FromUrl (url);
            printController.PrintInfo = printInfo;
            printController.PrintFormatter = webview.ViewPrintFormatter;

            bool success = printController.PrintToPrinter (printerObj, (handler, completed, error) => {...});


Sign In or Register to comment.