Show TOC Start of Content Area

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

In this example, the printer is in Graphic mode and prints rotated text. This program performs the following steps:

...

       1.      Opens the connection to the printer.

       2.      Obtains the text metrics, width, and height.

       3.      Prints the text drawn with a rotation of 180 degrees.

       4.      Closes the connection to the printer.

 

package test;

 

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

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

 

public class RotateText {

 

   public static void main(String[] args) {

      float x=0, y=0;

      String sText="This is a line of text.";

  

   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);

     

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

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

                 

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

        

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

 

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

         x = pF.getMetrics(sText).getWidth() + 10;

         y = pF.getHeight() + 15;

 

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

         gP.drawText(pF, x, y, sText, GraphicPrinter.ROTATE_180_DEGREES);

         gP.doPrint(1);

        

      }

      catch (Throwable error){

         error.printStackTrace();

      } finally {

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

         try {

            gP.close();

         } catch (Exception ex) {}

   }

      return;

   }

}

 

End of Content Area