I'm printing an HTML document from my application using a TWebBrowser
:
var WebHTML : TWebBrowser;
//Code to set up my TWebBrowser...
//Print the document:
WebHTML.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER); //or OLECMDEXECOPT_DONTPROMPTUSER
How can I set the margins to zero in the printout?
I've tried using WebHTML.Margins.SetBounds(0, 0, 0, 0);
, but the printout still has margins 0.75in. I've also set the padding and margins to zero in my CSS:
@page {
margin: 0in;
padding: 0in;
}
I think the problem is the printout is using the margin values set on the Page Setup dialog. I know this because when I call WebHTML.ExecWB(OLECMDID_PAGESETUP, OLECMDEXECOPT_PROMPTUSER, vaIn, vaOut);
, all margins are set to 0.75in... Which matches the margins in my printout.
I want to control these values without presenting the Page Setup dialog to the user.
The margin 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". The values margin_bottom, margin_left, margin_right, and margin_top can be set to 0.