Print string from xamarin android app to printer RRS feed

  • Question

  • User103806 posted

    Hi everyone,

    I have to print a ticket with string, qrcode and image.

    I have actually a TSP100-ECO from starmicronics but the library doesn't work ...

    What kind of printer are you using to print from android app ? And can you share your code please ?

    Thanks !

    Thursday, June 18, 2015 1:51 PM

All replies

  • User103806 posted

    Nobody can help me ? ...

    Friday, June 19, 2015 8:54 AM
  • User25759 posted

    Does this blog help out: http://blog.xamarin.com/native-printing-with-android/

    Saturday, June 20, 2015 11:17 PM
  • User103806 posted

    My device is in 4.1 Jelly Bean ... not in 4.4 KitKat

    Tuesday, June 30, 2015 8:10 AM
  • User263365 posted

    Hi, this run in Android 4.0.3 and upper. At first, it could be a sad trip for printing but you would need to purchase some more things for doing it: 1. A print server device (is a little device which can receive print commands and it is plugged on the usb port of your printer and configurated for connect to your wi-fi network) 2. Your Ticket printer documentation (this is for the commands that are only for that printer) 3. Your Android Device from 4.0.3 version

    At this point you won't need more than configure your print server with an IP and a Port, to access this through your cellphone by a Socket like the next example:

       private async Task Print()
            await Task.Run (() => 
                    //As you will see, all depends on your printer commands
                     Socket socket = new Socket(YOUR_PRINTSERVER_IP, YOUR_PRINSERVER_TCP_PORT);
                     PrintWriter pw = new PrintWriter (socket .OutputStream, true);
                     //here is the beginning of printing
                     pw.Write(0x1B); //Example of command to start a printer
                     pw.Print("THIS IS YOUR AWESOME TEXT FOR PRINT");
                     pw.Write(0x0C); //here you release the paper
                     pw.Write(0x40); //finish printing
                     pw.Flush ();
                     pw.Close ();
                     socket.Close ();
            catch(SocketException ex)
            Console.WriteLine("SocketError: "+ex.Message);

    And your principal advantage is an easier installation and it will receive all the print requests from all the devices which run your application like a local machine

    Tuesday, February 28, 2017 9:00 AM
  • User354584 posted

    @cvaldez I had tried out your code. But didn't worked for me. Is there anything specifically need to be done for Android. I tried providing print permission still same. Worked when tried to print an image from device using HP print client providing ip. No error and exceptions and tried debugging and saw connection status as true for socket. Any hint or advice on this is very helpful.

    Friday, October 20, 2017 4:47 PM