on 04-18-2007 7:53 AM
Hi, I'm trying to print a html document with this following java code but doesn't works:
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
}
This is not working because java.awt.Robot is a part of AWT package and intended for the client site, how I can make an action that when the
client push the print button. Print the html document automatly.
Regards,
Gabriel
Hi Gabriel,
AFAIK client-side eventing is not possible in webdynpro. But you can try this
<a href="/people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities:///people/sap.user72/blog/2006/05/04/enhancing-tables-in-webdynpro-java-150-custom-built-table-utilities. This may guide you to the right direction.
Regards
Abhinav Sharma
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I create into KM Content on portal a file called print.html and I put the following code:
<html>
<head />
<body onLoad="window.parent.focus(); window.parent.print();">
</body>
</html>
Because window.paren.print(); printed the code of actual iFrame. And into Web Dynpro I created a button that call the following function.
public void onActionPrintEncuestaPDF(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionPrintEncuestaPDF(ServerEvent) wdContext.currentPrintElement().setAtrURL("/irj/go/km/docs/documents/print/print.html");
//@@end
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Gabriel,
Quick and dirty solution:
1. Create HTML file within mimes folder below sub-folder with name of your component, name it for example print.html
2. Put the following inside HTML:
<html>
<head></head>
<body><button onclick="window.parent.print()">Print</button></body>
</html>
3. Put IFrame control on view, set url to print.html and adjust size as necessary
Valery Silaev
SaM Solutions
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.