Show TOC Start of Content Area

This graphic is explained in the accompanying text Text Drawn on the Right Side of the Page  Locate the document in its SAP Library structure

In this example the code draws text on the right side of the page. The printer is in Graphic mode. The program does as follows:

...

       1.      Opens the connection to the printer.

       2.      Uses page and font metrics to calculate the coordinates for the text to print on the right.

       3.      Draws the text at the calculated coordinates.

       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 TextRightGraphicMode {

 

   public static void main(String[] args) {

      float xRight=0, y=15;

      String sText="This text is on the right.";

        

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

         xRight = gP.getPageMetrics().getWidth() - pF.getMetrics(sText).getWidth() - 10;

                 

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

         gP.drawText(pF, xRight, y, sText, GraphicPrinter.NO_ROTATION);

         gP.doPrint(1);

        

      }

      catch (Throwable error){

         error.printStackTrace();

      } finally {

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

         try {

            gP.close();

         } catch (Exception ex) {}

   }

      return;

   }

}

 

End of Content Area