How do I send csv/text file from an Android phone to a wifi printer?

前端 未结 4 1816
心在旅途
心在旅途 2021-02-03 12:06

I am developing an Android application were I am supposed to get the data from a database in csv/txt file format and later I have to send the files to a wifi printer.

Do

相关标签:
4条回答
  • 2021-02-03 12:23

    You could read a data from database to a file directly. and then you can connect the printer via sockets or wifi. And then pass on to the printer.

    There are bunch of projects on github, maybe you can look at them, for example EasyPrinter.

    0 讨论(0)
  • 2021-02-03 12:28

    The answer was finally easy :

     Socket client = new Socket(_IP, PORT);
    
     oStream = new PrintStream(client.getOutputStream(), true, "UTF-8");
    
     oStream.println("-------------------------------------------------\r\n");
     oStream.println(" NAME     : DEMO CLIENT\r\n");
    oStream.println(" CODE  : 00000234242\r\n");
    oStream.println(" ADDRESS   : Street 52\r\n");
    oStream.println(" Phone : 2310-892345\r\n");
    oStream.println("-------------------------------------------------\r\n");
    
    oStream.flush();
    
    oStream.close();
    client.close(); 
    
    0 讨论(0)
  • 2021-02-03 12:30

    You can do this using sockets. You can get examples in these links http://examples.javacodegeeks.com/android/core/socket-core/android-socket-example/ Example: Android bi-directional network socket using AsyncTask

    and you can google it. (Socket programming via java and android examples)

    So first you must get your printer ip and port and send data to printer via a socket. To be ui friendly, you can create a setting form where you can set available printers ip and port

    0 讨论(0)
  • 2021-02-03 12:42

    Here's an Open Source project to print things with a Bixolon Bluetooth or WiFi printer on Android: https://github.com/rocboronat/FewlapsLovesBixolon

    0 讨论(0)
提交回复
热议问题