How to disable printing in CEF3?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

How to disable printing in CEF3?

Postby crast » Fri Sep 26, 2014 9:30 am

Hello!
I need to disable popup print dialog box.
I'm trying to reload PrintHandler in CefBrowserProcessHandler, but print dialog is pop up. How to do that?
crast
Techie
 
Posts: 15
Joined: Tue Sep 23, 2014 2:30 am

Re: How to disable printing in CEF3?

Postby magreenblatt » Fri Sep 26, 2014 12:36 pm

This is not currently supported. See https://code.google.com/p/chromiumembed ... il?id=1283.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: How to disable printing in CEF3?

Postby Czarek » Fri Sep 26, 2014 1:01 pm

You could overwrite window.print with a dummy function. In CefLoadHandler::OnLoadStart call frame->ExecuteJavascript("window.print=function(){}"); To disable "Print..." option from mouse context menu see CefContextMenuHandler.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: How to disable printing in CEF3?

Postby crast » Sat Sep 27, 2014 3:44 am

magreenblatt wrote:This is not currently supported.

I was confused by this preprocessor definitions:
ENABLE_PRINTING=1
ENABLE_FULL_PRINTING=1

Czarek wrote:In CefLoadHandler::OnLoadStart call frame->ExecuteJavascript("window.print=function(){}");

It works. Thanks.
crast
Techie
 
Posts: 15
Joined: Tue Sep 23, 2014 2:30 am

Re: How to disable printing in CEF3?

Postby rajeena » Mon Feb 18, 2019 6:00 am

Hi,
I am working on CEF application with CEF sharp with windows.

n CefLoadHandler::OnLoadStart call frame->ExecuteJavascript("window.print=function(){}");


will this work with windows applications as well?

The override the function look like this

public void OnFrameLoadStart(IWebBrowser chromiumWebBrowser, FrameLoadStartEventArgs frameLoadStartArgs)
{
frameLoadStartArgs.Frame.ExecuteJavaScriptAsync("window.print=function(){}");
}
Still print dialog pops up
Please help on this
rajeena
Techie
 
Posts: 11
Joined: Sun Dec 16, 2018 11:24 pm

Re: How to disable printing in CEF3?

Postby rajeena » Wed Feb 27, 2019 6:55 am

It worked by Modifying CEF Sharp source code by calling

frame->ExecuteJavascript("window.print=function(){}"); in CEfSharp.core ClientAdapter.cpp class OnLoadStart method
rajeena
Techie
 
Posts: 11
Joined: Sun Dec 16, 2018 11:24 pm

Re: How to disable printing in CEF3?

Postby ndesktop » Wed Feb 27, 2019 8:44 am

You can implement CEF menu handler and remove the print command.
ndesktop
Master
 
Posts: 756
Joined: Thu Dec 03, 2015 10:10 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 89 guests