Board index » delphi » Setting Page header/footer and margins from printing html page

Setting Page header/footer and margins from printing html page

Hi.

I have a program that encapsules web pages, using the TWebBrowser
component.
The program needs to print pages from the embedded HTML displays.

I handle the printing with code:

 HTMLDocument := browserwindow.FrmWindow.web2.Document as
IHTMLDocument2;
 HTMLWnd := HTMLDocument.Get_parentWindow;
 HTMLWindow3 := HTMLWnd as IHTMLWindow3;
 HTMLWindow3.print;

My problem is setting the printer margins (top and bottom), and also I
would like to get rid of the page header and footer.

How would I accomplish this using my print method?

Please could you cc a reply to luca...@bigfoot.com, if possable.

Regards
Lucas

 

Re:Setting Page header/footer and margins from printing html page


Quote
luca...@bigfoot.com (Lucas) wrote in message <news:c0377caa.0205150318.3ca25abb@posting.google.com>...
> Hi.

> I have a program that encapsules web pages, using the TWebBrowser
> component.
> The program needs to print pages from the embedded HTML displays.

> I handle the printing with code:

>  HTMLDocument := browserwindow.FrmWindow.web2.Document as
> IHTMLDocument2;
>  HTMLWnd := HTMLDocument.Get_parentWindow;
>  HTMLWindow3 := HTMLWnd as IHTMLWindow3;
>  HTMLWindow3.print;

> My problem is setting the printer margins (top and bottom), and also I
> would like to get rid of the page header and footer.

> How would I accomplish this using my print method?

> Please could you cc a reply to luca...@bigfoot.com, if possable.

> Regards
> Lucas

Well, I got a way to do this, by manipulating the registry. Maybe not
the cleanest method, but it works quite well.

Look at registry key:

HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup

By storing the current values, then setting them to the values I want,
then call the print command, and then setting the values back to the
original values, thus restoring a users own settings.

Worked on 98 and NT based OS.

Lucas

Other Threads