Show TOC Start of Content Area

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

In this example, the printer is in Graphic mode and prints a rotated barcode.

Note

Rotation of a barcode is possible only with the printer in graphic mode.

The program performs the following steps:

...

       1.      Sets the Full ASCII and Check Digit Mod43 symbology options.

       2.      Opens the connection to the printer.

       3.      Selects the Human Readable Below, Default Density, and Double Scale barcode settings.

       4.      Encodes the data, 32123, using ASCII.

       5.      Obtains the metrics for the barcode.

       6.      Prints the barcode rotated by 270 degrees.

       7.      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 RotateBarcode {

 

   public static void main(String[] args) {

      float x=0, y=0;

     

   GraphicPrinter gP = null;

      try{

        

         Connector conn = Connector.getInstance();

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

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

         params.setPrinterMode(PrinterParameters.GRAPHIC_MODE);

 

         Symbology symbology = new Code39();

 

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

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

     

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

         gP = (GraphicPrinter) conn.open(params);

 

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

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

         barcode.setDensity(PrinterBarcode.DENSITY_DEFAULT);

         barcode.setHeight(10);

         barcode.setScaleFactor(PrinterBarcode.SCALE_DOUBLE);

 

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

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

        

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

         x = barcode.getHeight() + 10;

         y = barcode.getMetrics(data).getWidth() + 15;

        

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

         gP.drawBarcode(barcode, x, y, data,GraphicPrinter.ROTATE_270_DEGREES);          

         gP.doPrint(1);

 

      }

      catch (Throwable error){

         error.printStackTrace();

      } finally {

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

         try {

            gP.close();

         } catch (Exception ex) {}

   }

      return;

   }

}

 

End of Content Area