Show TOC Start of Content Area

This graphic is explained in the accompanying text Configure Printer Parameters  Locate the document in its SAP Library structure

In this example, the printer is in Line mode and changes a printer parameter in the piprmswin32 driver, prints a report, and resets the print driver parameter. The program performs the following steps:

...

       1.      Opens connection to the printer.

       2.      Obtains the configuration manager for the driver.

       3.      Obtains the driver parameter using the configuration manager.

       4.      Sets the driver parameter value to True.

       5.      Closes and reopens the connection to the printer for the change to the parameter value to take effect.

       6.      Prints sample text.

       7.      Resets the parameter to False.

       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.configuration.*;

 

public class ConfigurePrinterParameters {

 

   public static void main(String[] args) {

     

     

    LinePrinter lP = null;

    try {

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

         Connector conn = Connector.getInstance();

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

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

         params.setPrinterMode(PrinterParameters.LINE_MODE);

     

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

        

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

         DriverConfigurationManager manager = lP.getParameters().getDriver().getConfigurationManager();

 

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

         Configuration config1 = manager.getConfiguration("DriverParameters");

        

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

         String promptUser = config1.getParameters()[0];

         config1.setParameterValue(promptUser, "true");

         manager.save();

 

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

         lP.close();

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

  

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

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

         PrinterFont pF = null;

         if (sFonts != null) {

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

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

            lP.printText(pF, " This is a test string.", LinePrinter.NO_ALIGNMENT);

            pF = lP.getFont(sFonts[1]);

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

            lP.printText(pF, " This is a test string.", LinePrinter.NO_ALIGNMENT);

 

            lP.doPrint(1);

         }

 

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

         manager = lP.getParameters().getDriver().getConfigurationManager();

         config1 = manager.getConfiguration("DriverParameters");

         promptUser = config1.getParameters()[0];

         config1.setParameterValue(promptUser, "false");

         manager.save();

        

      }

      catch (Throwable error){

         error.printStackTrace();

      } 

      finally {

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

         try {

            lP.close();

         } catch (Exception ex) {}

      }

           

      return;

   }

}

 

End of Content Area