LAMW: Print to network printer lazarus / 43-Android ---------------------------------------------------------------------- dseligo · 2023-11-26 17:19 How to print directly to a network printer? I found some example in Java, but I don't know how to translate it to Free Pascal: https://riggaroo.dev/simple-printing-in-android-to-a- network-printer/ Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DataOutputStream outToServer;Socket clientSocket;try {   createHtmlDocument(htmlString);   FileInputStream fileInputStream = new FileInputStream(android.os.Environment.getExternalStorageDirectory()  + java.io.File.separator+ "test.pdf");   InputStream is =fileInputStream;   clientSocket = new Socket(ipAddress, portNumber);   outToServer = new DataOutputStream(clientSocket.getOutputStream());   byte[] buffer = new byte[3000];   while (is.read(buffer) !=-1){      outToServer.write(buffer);   }   outToServer.flush();   return 1;}catch (ConnectException connectException){   Log.e(TAG, connectException.toString(), connectException);   return -1;}catch (UnknownHostException e1) {   Log.e(TAG, e1.toString(), e1);   return 0;} catch (IOException e1) {   Log.e(TAG, e1.toString(), e1);   return 0;}finally {   outToServer.close(); } ---------------------------------------------------------------------- loaded · 2023-11-27 06:01 First of all, it is worth noting that LAMW uses java in the background. I recommend you to examine LAMW examples on the subject. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ..\lazandroidmodulewizard-master\demos\GUI\Probably the AppIntentDemoPrinting1 example can be of use to you. I take the following approach: In my application, I first convert the output to pdf and then leave the initiative to the user. User ; - If it wants, it can send it directly to the wired/wireless printer itself. - Can save as pdf if desired then send to printer or bluetooth or whatsapp at a later time. However, I do most of the above operations directly in Java in Android Studio. ---------------------------------------------------------------------- dseligo · 2023-11-27 08:22 Quote from: loaded on November 27, 2023, 07:01:10 amProbably the AppIntentDemoPrinting1 example can be of use to you. I saw that example, but it is not direct printing, it calls 3rd party applications. Furthermore, first application wants upgrade to premium to use network printer, and second application is made for older version of Android. I want to print without further user interaction (I have IP address of the printer stored in the settings). Also, printing on Windows shared printers would also be great. ---------------------------------------------------------------------- loaded · 2023-11-28 06:15 Quote from: dseligo on November 27, 2023, 09:22:08 amI saw that example, but it is not direct printing, it calls 3rd party applications. Furthermore, first application wants upgrade to premium to use network printer, and second application is made for older version of Android. I want to print without further user interaction (I have IP address of the printer stored in the settings). Also, printing on Windows shared printers would also be great. I understand you're right. I'm at work right now and unfortunately I don't have the opportunity to run these examples, so I want to tell you about what I do in such situations. When I encounter such problems, I use Android Studio + LAMW to find solutions more easily. When it comes to Android-related operations, I first make my experiments on Android Studio. After the project runs smoothly, I add java codes to LAMW as needed. First of all, I believe that Master jmpessoa, one of the authors of LAMW, can easily find the solution to this problem. Or if you examine the files below, you will see the working logic of LAMW more clearly. You can then modify it according to your needs. Of course, all of these processes will require some trial and error. Regarding the subject, Java Files used by LAMW. The java files here are transferred to the relevant projects. (You can make changes in these files.); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...\lazandroidmodulewizard-master\android_wizard\smartdesigner\java Pas files that provide links to Java files. (You can make changes in these files.); Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...\lazandroidmodulewizard-master\android_bridges The java files used by the printing example mentioned in the previous message are; Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ...\lazandroidmodulewizard-master\demos\GUI\AppIntentDemoPrinting1\src \org\lamw\appintentdemoprinting1 Note: This approach may not be very professional. I welcome experts to offer their criticisms.