Skip to main content



      Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Printing HTML from SWT Browser widget
Printing HTML from SWT Browser widget [message #435936] Fri, 07 May 2004 16:20 Go to next message
Eclipse UserFriend
Originally posted by: boesen.itu.dk

Hi,

I am looking for at way to print HTML pages from an SWT application,
preferably using the SWT Browser widget. Is there a way to get the
browser widget to print the current contents? Or any suggestions for
good alternatives?

Thanks,
Thomas P. Boesen
Re: Printing HTML from SWT Browser widget [message #436027 is a reply to message #435936] Sun, 09 May 2004 05:08 Go to previous messageGo to next message
Eclipse UserFriend
https://bugs.eclipse.org/bugs/show_bug.cgi?id=44823

Hope this helps.


Thomas P. Boesen wrote:

> Hi,
>
> I am looking for at way to print HTML pages from an SWT application,
> preferably using the SWT Browser widget. Is there a way to get the
> browser widget to print the current contents? Or any suggestions for
> good alternatives?
>
> Thanks,
> Thomas P. Boesen
>
Re: Printing HTML from SWT Browser widget [message #436028 is a reply to message #435936] Sun, 09 May 2004 05:15 Go to previous message
Eclipse UserFriend
This is my solution for Windows SWT:



package org.eclipse.swt.browser;

import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.ole.win32.*;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.swt.widgets.Composite;

public class PrintableBrowser extends Browser {

public PrintableBrowser(Composite parent, int style) {
super(parent, style);
}

public void print(boolean showStdSetupDialog) {
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());
// }
}

public void pageSetup() {
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_PAGESETUP);

//OLECMDEXECOPT_PROMPTUSER = 1
//OLECMDEXECOPT_DONTPROMPTUSER = 2
rgvarg[1] = new Variant(1);

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());
// }
}

}
Previous Topic:support for headless ActiveX controls
Next Topic:Preserving Selection in TreeViewer
Goto Forum:
  


Current Time: Sat Jul 05 12:45:13 EDT 2025

Powered by FUDForum. Page generated in 0.04615 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top