From aa5644ca43e559cbcfb747c12aceec9368197229 Mon Sep 17 00:00:00 2001 From: Joshy Date: Fri, 4 Mar 2011 12:35:25 +0000 Subject: [PATCH] Added Print (to printer) method. git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1521 8e941d3f-bd1b-0410-a28a-d453659cc2b4 --- .../geckoport/Components/GeckoBrowser.pas | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/components/geckoport/Components/GeckoBrowser.pas b/components/geckoport/Components/GeckoBrowser.pas index 15daf622a..1c5a76097 100755 --- a/components/geckoport/Components/GeckoBrowser.pas +++ b/components/geckoport/Components/GeckoBrowser.pas @@ -453,6 +453,8 @@ type class function GetGeckoBrowserWithDOMWindow(constref DOMWindow: nsIDOMWindow): TGeckoBrowser; + procedure Print(const aShowPrinterSelectDialog: Boolean); + published property OnDOMLoad: TGeckoBrowserDOMEventHandler read FOnDOMLoad write FOnDOMLoad; @@ -1841,6 +1843,23 @@ begin end; end; +procedure TGeckoBrowser.Print(const aShowPrinterSelectDialog: Boolean); +var + PrintInterface: nsIWebBrowserPrint; + PrintSettings: nsIPrintSettings; +begin + PrintInterface:=GetWebBrowserPrint; + if Assigned(PrintInterface) then begin + PrintSettings:=PrintInterface.GetGlobalPrintSettings; + if Assigned(PrintSettings) then begin + PrintSettings.ShowPrintProgress:=false; //true implies need of nsIWebProgressListener + PrintSettings.PrintBGImages:=true; + PrintSettings.SetPrintSilent(not aShowPrinterSelectDialog); + end; + PrintInterface.Print(PrintSettings,nil); + end; +end; + function TGeckoBrowserChrome.NS_GetInterface(constref uuid: TGUID; out _result): nsresult; begin if IsEqualGUID(uuid, nsIDOMWindow) then @@ -2021,6 +2040,7 @@ function TCustomGeckoBrowser.GetWebBrowserFind: nsIWebBrowserFind; begin Result := FWebBrowser as nsIWebBrowserFind; end; + function TCustomGeckoBrowser.GetWebBrowserPrint: nsIWebBrowserPrint; var ir:nsIInterfaceRequestor; @@ -2030,6 +2050,7 @@ begin ir.GetInterface(nsIWebBrowserPrint, wbp); Result := wbp; end; + function TCustomGeckoBrowser.GetWebNavigation: nsIWebNavigation; begin Result := FWebBrowser as nsIWebNavigation;