Problem - Print a document using LibreOffice in Linux

We are trying to print a word document using LIbreoffice API in java(Linux environment). We got the below program from the Libreoffice official site to print a word document. We used the same program and modified only three parameters

  1. Document Path
  2. Printer Name
  3. Number of Pgaes

The code executes completely but we have received our printout in the required printer. We are trying to print docx file. When we tried to print the document using command prompt, it is working fine. Please find the command we used.

This shows there is no issues in the Printer Configuration or libreoffice installation or the document.

Please ssuggest is there anything we are doing wrong here. PFB, program for your reference. We have taken this program from libreoffice official site.

          try {
              
              XComponentContext xContext = null;
              String oooExeFolder = "D:\\OpenOffice 4\\program\\";
              // get the remote office component context
               xContext = BootstrapSocketConnector.bootstrap(oooExeFolder);
      
              // get the remote office service manager
              com.sun.star.lang.XMultiComponentFactory xMCF =
                  xContext.getServiceManager();

              Object oDesktop = xMCF.createInstanceWithContext(
                  "com.sun.star.frame.Desktop", xContext);

              com.sun.star.frame.XComponentLoader xCompLoader =
                  (XComponentLoader) UnoRuntime.queryInterface(
                    com.sun.star.frame.XComponentLoader.class, oDesktop);

              File file = new File("D:\\Test.doc");
	  //filename should be with complete path

                        
              java.io.File sourceFile = new java.io.File("D:\\Test.doc"); 
              StringBuffer sUrl = new StringBuffer("file:///");
              sUrl.append(sourceFile.getCanonicalPath().replace('\\', '/'));
               

              // Load a Writer document, which will be automaticly displayed
              com.sun.star.lang.XComponent xComp = xCompLoader.loadComponentFromURL(
                  sUrl.toString(), "_blank", 0,
                  new com.sun.star.beans.PropertyValue[0] );

              // Querying for the interface XPrintable on the loaded document
              com.sun.star.view.XPrintable xPrintable =
                  (XPrintable) UnoRuntime.queryInterface(
                    com.sun.star.view.XPrintable.class, xComp);

              // Setting the property "Name" for the favoured printer (name of
              // IP address)
              com.sun.star.beans.PropertyValue propertyValue[] =
                  new com.sun.star.beans.PropertyValue[1];
              propertyValue[0] = new com.sun.star.beans.PropertyValue();
              propertyValue[0].Name = "Name";
              propertyValue[0].Value = "myPrinter01";
              System.out.println("Printer Name "  + propertyValue[0].Value );
              
              // Setting the name of the printer
              xPrintable.setPrinter( propertyValue );

              // Setting the property "Pages" so that only the desired pages
              // will be printed.
              propertyValue[0] = new com.sun.star.beans.PropertyValue();
              propertyValue[0].Name = "Pages";
              propertyValue[0].Value = "1";

              // Printing the loaded document
              xPrintable.print( propertyValue );

             // System.exit(0);
      System.out.println("propertyValue" + propertyValue);
              
  
  }  catch (Exception e) {
        e.printStackTrace();      
  }