Show TOC Start of Content Area

This graphic is explained in the accompanying text Print Barcode in Line Mode  Locate the document in its SAP Library structure

In this example, the printer is in Line mode and prints a barcode using Code 39 symbology. The Full ASCII and Check Digit mod43 options are selected for the symbology. The program performs the following steps:

...

       1.      Opens the connection to the printer.

       2.      Creates a barcode with Human Readable Below.

       3.      Sets the density for the barcode to the default.

       4.      Sets the height of the barcode to 10.

       5.      Sets the Scale of the barcode to Double.

       6.      Encodes the data used, 10101, using ASCII.

       7.      Sends the barcode to the printer.

       8.      Closes the connection to the printer.

 

package test;

 

import com.sap.ip.me.api.pios.connection.*;

import com.sap.ip.me.api.pios.printer.*;

import com.sap.ip.me.api.pios.symbology.*;

 

public class BarcodeLineMode {

 

   public static void main(String[] args) {

        

   LinePrinter lP = null;

  

      try{

         Connector conn = Connector.getInstance();

         DriverInfo[] driverInfo = conn.listDrivers(ConnectionType.PRINTER);

         PrinterParameters params = new PrinterParameters(driverInfo[0]);

         params.setPrinterMode(PrinterParameters.LINE_MODE);

 

         Symbology symbology = new Code39();

         symbology.setOptions(Code39.FULLASCII | Code39.CHECK_DIGIT_MOD43);

 

         //----------------------(1)--------------------   

         lP = (LinePrinter) conn.open(params);

         String[] sFonts = lP.getFontConfigurationManager().listFontNames();

         PrinterFont pF = lP.getFont(sFonts[0]);

        

         //----------------------(2)--------------------

         PrinterBarcode barcode = lP.createBarcode(symbology, PrinterBarcode.HUMAN_READABLE_BELOW);

 

         //----------------------(3)--------------------

         barcode.setDensity(PrinterBarcode.DENSITY_DEFAULT);

 

         //----------------------(4)--------------------

         barcode.setHeight(10);

 

         //----------------------(5)--------------------

         barcode.setScaleFactor(PrinterBarcode.SCALE_DOUBLE);

 

         //----------------------(6)--------------------

         byte[] data = "10101".getBytes("ASCII");

 

         //----------------------(7)--------------------

         lP.printText(pF, "", LinePrinter.NO_ALIGNMENT);

         lP.printBarcode(barcode, data, LinePrinter.ALIGN_CENTER);     

         lP.doPrint(1);

 

      }

      catch (Throwable error){

         error.printStackTrace();

      } finally {

         //----------------------(8)--------------------

         try {

            lP.close();

         } catch (Exception ex) {}

      }

      return;

   }

}

 

End of Content Area