delphiprintingtwebbrowserpage-setup

Control page setup options in Delphi without showing Page Setup dialog


In my Delphi application, I can use the following code to show the Page Setup dialog to my users before printing.

//WebHTML is a TWebBrowser with a Document loaded.
WebHTML.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER);

Page Setup Dialog

Is it possible to change these page setup options using code (without showing the Page Setup dialog to my users)? I specifically want to control the Header and Footer options so that all users will have the same headers and footers.


Solution

  • The page setup settings are saved and loaded using Windows Registry keys. I wrote code to change the keys at the location "Computer\HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup".

    Internet Explorer Page Setup registry keys