Community
Participate
Working Groups
I need to print the content of the Browser widget (Send Html page to printer). So I think it's very useful to supply the method public void print() throws PrintException and more cool method public void print(PrintData printData) throws PrintException Where PrintData contains information about how to print (Lanscape or Portrait, paper size etc). I know this is very difficult (impossible) to realize in case of MSHTML ActiveX. May be it's can be done with Mozilla-based Html SWT widget?
Hi Alexander, To answer your post from 16/10/2003: adding printing support is not being investigated at the moment (see http://dev.eclipse.org/viewcvs/index.cgi/% 7Echeckout%7E/platform-swt-home/faq.html#browserstate). You can vote for this PR and if you wish to help, you can also provide printing implementations on the platforms supported by the Browser widget. Chris
Simpliest solution for IE can be to add in Browser.java I'm not sure it's absolutely correct. This is just idea. Please check it because I can't compile SWT public void print() throws BrowserPrintException { print(false); } public void print(boolean showStdSetupDialog) throws BrowserPrintException { checkWidget(); int[] rgdispid = auto.getIDsOfNames(new String[] { "ExecWB", "cmdID","cmdexecopt" }); Variant[] rgvarg = new Variant[2]; //OLECMDID_PRINT is const from MS headers rgvarg[0] = new Variant(OLE.OLECMDID_PRINT); //OLECMDEXECOPT_PROMPTUSER = 1 //OLECMDEXECOPT_DONTPROMPTUSER = 2 rgvarg[1] = new Variant(showStdSetupDialog ? 1 : 2); int[] rgdispidNamedArgs = new int[2]; rgdispidNamedArgs[0] = rgdispid[1]; rgdispidNamedArgs[1] = rgdispid[2]; Variant pVarResult = auto.invoke(rgdispid[0], rgvarg, rgdispidNamedArgs); // If prev code is worked then add error handling // if(pVarResult.getType() == OLE.VT_EMPTY) { // throw new BrowserPrintException(pVarResult.getType()); // } } Additional info see in help about ExecWB method of the MSHTML More flexible variant of this function is very difficult to implement with MS ActiveX because it seems don't support such flaxible tuning before print. There are ExecWB with 4 arguments may be pvaIn argument can help????
As a workaround you can use print() from JavaScript. The problem is that this doesn't work in SWT Mozilla Widget on Linux with 3.0M6 since the dialog is not displayed. At least you could fix the problem to display the Mozilla dialogs so that the javascript woraround can be used.
JavaScript is not the workaround because of it don't get me control when and how to print. How can I access to the JavaScript function from my SWT Java program? BTW JavaScript + ScriptX seems to be only way programaticaly to control page parameters: paper size, landscape or portrait etc in the MSHTML ActiveX
*** Bug 47937 has been marked as a duplicate of this bug. ***
It may be obvious, but if you don't want to put javascript print() function inside the document you're printing, you may just call browser.setLocation("javascript:print()"); to get the same effect for browsers that support it. This way you may decide when to print the document.
Javascript printing is a workaground, but since the browser keeps poping up the select printer dialog so basically it can't do batch printing. We need to do batch printing of many html files. I tried the Java Print API but there is no service implementation for html. If the SWT browser can provide a print method to bypass the dialog, that would be a very cool feature. Thx
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.