CefSharp icon indicating copy to clipboard operation
CefSharp copied to clipboard

How to implementation CefPrintHandler?

Open feliciwithme opened this issue 11 years ago • 7 comments

In CefSharp.Core.dll ClientAdapter not implementation CefPrintHandler.

CefClient.h not implementation GetPrintHandler method.

https://bitbucket.org/chromiumembedded/cef/src/2782fb8fc85f55b87ea3c8bedaccec243eba65ed/include/cef_client.h?at=2454&fileviewer=file-view-default

feliciwithme avatar Nov 27 '15 09:11 feliciwithme

@feliciwithme I've replaced your large hard to read code block with a link to the CEF source.

I'm not really sure what your asking?

Implement this interface to handle printing on Linux. The methods of this class will be called on the browser process UI thread.

The CefPrintHandler is only relevant on Linux according to the documentation.

http://magpcss.org/ceforum/apidocs3/projects/%28default%29/CefPrintHandler.html

amaitland avatar Nov 27 '15 09:11 amaitland

How Implement this interface to handle printing on windows? I want to implment printing without the popup printsetting dialog, When user click print button to direct print without choice printdialog.

feliciwithme avatar Nov 27 '15 10:11 feliciwithme

Unfortunately there is no simple solution for that. CEF has limited options.

See http://magpcss.org/ceforum/viewtopic.php?f=6&t=12567#p24126 for official comment from the CEF maintainer.

I think the general workaround is export to PDF, then print that.

amaitland avatar Nov 27 '15 10:11 amaitland

@amaitland Thank you very much, I want to give it a shoot.

feliciwithme avatar Nov 27 '15 10:11 feliciwithme

I am using CEFSharp 42 from Nuget and am struggling to locate the PrintToPDF that I can see here.

PrintToPdf is part of the 45.0.0 release, the relevant PR is #1278

is there an example for winforms?

There is a WPF example, the code isn't particularly WPF specific, so most parts should translate.

https://github.com/cefsharp/CefSharp/blob/cefsharp/45/CefSharp.Wpf.Example/MainWindow.xaml.cs#L110

amaitland avatar Nov 27 '15 12:11 amaitland

I just read a thread that stated is was a part of 45 so deleted my post here whilst I tried that -your too fast :)

thank you - example is perfect

dandotevans avatar Nov 27 '15 12:11 dandotevans

Closing this as there is no need to implement CefPrintHandler (Linux only). If anyone has a specific question as followup, please create a new issue.

amaitland avatar Dec 01 '15 07:12 amaitland