Silently print CefGlue in PDF

I have latests version of CefGlue (3.2272.2035)

I need to save the current page as a PDF. I would like to somehow interact with CEF (JS / C #) and create a PDF file for it.

  • I tried to use javascript.window.print () for this purpose without success, because I have such a window.

enter image description here

  1. I found the OnPrintJob method in CefPrintHandler, but I donโ€™t know how to call it correctly + comments say: โ€œImplement this interface for processing printing on Linuxโ€ and I need to process pdf printing in Windows environments (like x64 / x86).

Any code sample would be appreciated. Thank you in advance for any help.

+5
source share
1 answer

You need to combine this patch and recompile cef from the source code; In addition, you may need to add CefGlue glue logic. I tested the patch myself (using the C ++ API) and it worked fine.

EDITED: The patch will be merged into the torso.

If you only need to print several pages (especially if these pages are under your control), you will do everything in order. However, if you need (as at that time) to print almost everything, you will probably find that some web pages do not display anything useful for the type of print. In addition, even those who behave themselves are significantly different from what you see on the screen - and this is not CEF behavior, since even google chrome showed the same problems. This was not good in my application, so I refused to print and started to capture the screen (and implemented saving this to pdf using the pdf library in C ++), but maybe your application is not as demanding as mine. Hurrah!

+1
source

All Articles