cancel
Showing results for 
Search instead for 
Did you mean: 

CTRL+P print with robot class

Former Member
0 Kudos

Hi, I'm trying to print a html document with this following java code:

  public void onActionPrintEncuestaPDF(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionPrintEncuestaPDF(ServerEvent)
	try{
		Robot robot = new Robot();
            
		
		// Ctrl+P
		robot.keyPress(KeyEvent.VK_CONTROL );		
		robot.keyPress(KeyEvent.VK_P );		
		robot.keyRelease(KeyEvent.VK_CONTROL);
		robot.keyRelease(KeyEvent.VK_P );
            
		Thread.sleep(500);
            
		//Alt+U
		robot.keyPress(KeyEvent.VK_ALT );
		robot.keyPress(KeyEvent.VK_U );
		robot.keyRelease(KeyEvent.VK_ALT );
		robot.keyRelease(KeyEvent.VK_U );
            
		Thread.sleep(500);
            
		//entrée
		robot.keyPress(KeyEvent.VK_ENTER);
		robot.keyRelease(KeyEvent.VK_ENTER );
            
		Thread.sleep(500);

	}
	catch(Exception e){  }

    //@@end
  }

But unafortunately doesn't work. Somebody knows what happends?

Thanks!

Accepted Solutions (0)

Answers (2)

Answers (2)

dmitryjirov
Explorer
0 Kudos

You can probably try to build a client side application which will control Internet Explorer with your application. I'd say automated testing tools would do the same without programming efforts.

Regards,

Dmitry

dmitryjirov
Explorer
0 Kudos

Hi Gabriel,

java.awt.Robot class is a part of AWT package and intended for the client side Java GUI, your Web Dynpro code runs on the server side.

Best regards,

Dmitry

Former Member
0 Kudos

Ok, and there are any posibility or solution to run this code for the client side Java GUI?

Thanks