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.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.
grl wrote: Mon Apr 03, 2017 7:44 pm
But on one of those the printer will constantly choose the wrong paper size. You can open the printer properties in the printing dialog and change it there then the printout is just fine. But the next report it's back to the old setting.
Looks like the default paper size for that printer in that computer is not configured correctly.
Take a look at all the tabs and "advanced properties" buttons inside the "properties" of that printer.
Some times you have to set the right page size in several places.
There's a function in TCefBrowserProcessHandler called "get_print_handler".
According to the CEF3 sources in /include/capi/cef_browser_process_handler_capi.h that function returns the handler for printing in LINUX but it has exactly what you need : access to the printer settings.
Right now CEF4Delphi doesn't implement that function because this project only works in windows but I'll take a look...
Download the latest CEF4Delphi. It has a couple of new context menu options that modify the HTML to set a new printing page size and another option to print from javascript.
The CSS modifications I mentioned in this thread are included in the MiniBrowser demo.
To test them you need to do the following :
Right-click on a web page and select "Modify HTML document" to add a few CSS lines at the end of the HEAD element. Open the DevTools to check if the web page you're trying to print has included this new CSS code :