printer.jsp


<html>
<head>
<%@ page import="com.sap.ip.me.api.pios.connection.*" %>
<%@ page import="com.sap.ip.me.api.pios.printer.*" %>

<!--  You can place a image here to return to ME home page: 127.0.0.1 = localhost on the Desktop and also works on the PDA
   <a href="http://127.0.0.1:4444/me" > <img src="mimes/myGIF.gif" alt="ME Home" ></a>
   -->
</head>
<body>
  <jsp:useBean id="servletToJSPBean" scope="session" class="printerAPIExample1.bean.dataBean" />
<!-- For event handling we need a HTML "form" command -->
 <form method="post" action="start" id="myForm1" name="form">

<!-- Display title of the example -->
   <h4>Print "SAP MI - more printing power"</h4><br>
   
   Look at the Emulator.

<%

        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);
        
            gP = (GraphicPrinter) conn.open(params);
            
            String[] sFonts = gP.getFontConfigurationManager().listFontNames();
            PrinterFont pF = gP.getFont(sFonts[0]);
            gP.drawText(pF, 10, 10, "SAP MI - more printing power", 0);
            gP.doPrint(1);
            
            gP.close();
        }
        catch (Throwable error){
            error.printStackTrace();
        }
        finally{
            try{
                gP.close();    
            }
            catch (Exception ex){
            }
        }
%>

    
 </form>
</body>
</html>