0 Replies Latest reply: Sep 19, 2013 10:17 AM by Simarjeet RSS

    Printing to a label printer

    Simarjeet


      How i can use BI publisher to print to a label printer? Label printer doesn't support postscript but it does support XML printing.

       

      In code, we use following code for normal printers. We are sending PDF as input stream. What changes we need in this code to print to a label printer?

       

       

      public static void printDoc(String filePath,String printerName,InputStream in) throws Exception {

       

          try {

              DeliveryManager dmpr = new DeliveryManager();

              // create a delivery request

              DeliveryRequest reqp =

                  dmpr.createRequest(DeliveryManager.TYPE_IPP_PRINTER);

              // set IPP printer host

              reqp.addProperty(DeliveryPropertyDefinitions.IPP_HOST, "PR12");

              reqp.addProperty(DeliveryPropertyDefinitions.IPP_PORT, "80");

              reqp.addProperty(DeliveryPropertyDefinitions.IPP_PRINTER_NAME,

                               "/printers/"+printerName+"/.printer");

              System.out.println("Print requested for printer: "+printerName);

              // set the document format

              reqp.addProperty(DeliveryPropertyDefinitions.IPP_DOCUMENT_FORMAT,

                               DeliveryPropertyDefinitions.IPP_DOCUMENT_FORMAT_PLAINTEXT);

              if(!StringUtils.isEmpty(filePath)){

                  // set the document

                

                  reqp.setDocument(filePath);

       

                  // submit the request

                  reqp.submit(new PrintDocumentListener(filePath));

              }

              else{

                  reqp.setDocument(in);

                

                  // submit the request

                  reqp.submit();

                  // close the request

                 reqp.close();

              }

            

          } catch (Exception e) {

              // TODO: Add catch code

              e.printStackTrace();

              throw new Exception("Error occured while printing document");

          }

       

      }