Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

working with Printer

Post Reply
User avatar
salvadordf
Posts: 4074
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: working with Printer

Post by salvadordf »

Hi,
aveliks wrote: Fri Aug 31, 2018 8:27 am Hi All!
Can I use in CEF chrome.printerprovider API?
if not- can any help me with some ideas about how to catch an attemp to print from CEF?
I've never tried that API in CEF and I can't find anyone asking about it.
I guess you can only test it for yourself or ask in the official CEF3 forum. Remember that CEF4Delphi is just a CEF3 wrapper.

http://www.magpcss.org/ceforum/
User avatar
salvadordf
Posts: 4074
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: working with Printer

Post by salvadordf »

aveliks wrote: Fri Aug 31, 2018 9:24 am how I can catch up or redirect Ctrl+P or windows.print() in my Delphi app win CEF4Delphi?
as I can see in demo and in BriskBard browser - it not so easy ... isn't?
I need in my app redirect any attempting to print web-page to printtopdf function instead standard print due I've need to print header and footer in pages.
As far as I know, CEF3 doesn't give you the possibility to redirect any print job. The demos and BriskBard use the standard CEF3 printing procedures.

I can only suggest these solutions :
  • Find a PDF printer driver that allows you to add custom headers and footers to all the print jobs and install it in the client computer. Remove all other printers from Windows control panel and you will not have to redirect printing jobs because there's only one printer available.
  • Use the Detours library to hook PrintDlg and PrintDlgEx. I've never tried this but if Chromium code uses PrintDlg or PrintDlgEx to show the printer selection dialog then you can intercept those calls and print directly to PDF. Here's the library : https://github.com/MahdiSafsafi/delphi-detours-library
I use the Detours library to remove a DOS window that pops up every time the Flash plugin is executed. You have more details here :
https://www.briskbard.com/forum/viewtop ... =137&p=706
Post Reply