Knowledge Base
HOWTO: Change Print Settings for Internet Explorer and WebBrowser Control ProgrammaticallyPSS ID Number: 236777
Article Last Modified on 12/7/2002
--------------------------------------------------------------------------------
The information in this article applies to:
Microsoft Internet Explorer (Programming) 4.0
Microsoft Internet Explorer (Programming) 4.01
Microsoft Internet Explorer (Programming) 4.01 SP1
Microsoft Internet Explorer (Programming) 4.01 SP2
Microsoft Internet Explorer (Programming) 5
--------------------------------------------------------------------------------
This article was previously published under Q236777
IMPORTANT: This article contains information about modifying the registry. Before you modify the registry, make sure to back it up and make sure that you understand how to restore the registry if a problem occurs. For information about how to back up, restore, and edit the registry, click the following article number to view the article in the Microsoft Knowledge Base:
256986 Description of the Microsoft Windows Registry
SUMMARY
This article explains how to set page margins, header and footer information, and the default printer for printing from Internet Explorer and the WebBrowser control programmatically.
MORE INFORMATION
Users can easily change page margins, header and footer settings, and the default Internet Explorer printer through the Internet Explorer user interface.
However, there are no methods under Internet Explorer or the WebBrowser control to change these settings programmatically.
You cannot use the ExecWB command to set page margins and the header or footer.
These values are stored in the registry.
There might be a need to change the print settings of Internet Explorer or the WebBrowser control programmatically. The only settings that can be changed are page margins, and header and footer information. There is no supported way to change other settings like page orientation or printer.
WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.
This is how Microsoft Internet Explorer accesses the printing settings:
For Page Margins, Microsoft Internet Explorer first tries to get the values from this registry key:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
If there is no such a key, Internet Explorer create this key by copying the values from the following:
HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\PageSetup
If there is no such key, default values are provided.
For the Header and Footer, the values are picked up from the following:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup
If there is no such key, default values are provided.
The defaults are 0.75 for margins,
For the Internet Explorer default printer, default values are provided from:
HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\PageSetup\printer
The developer could alter the above registry entries for the printing settings accordingly.
Please note that these values are system-wide and affect all instances of the WebBrowser control and Internet Explorer for the current user.
REFERENCES
For a Microsoft Visual Basic .NET version of this article, see 311280.
For additional information, click the article numbers below to view the articles in the Microsoft Knowledge Base:
145679 HOWTO: Use the Registry API to Save and Retrieve Setting
156732 HOWTO: Print from the Microsoft WebBrowser Control
176400 HOWTO: Print the WebBrowser Control
188271 HOWTO: Print Contents of the Web Browser Control From VB
256898 Default Printer for Internet Explorer or Outlook Express May Be Incorrect
For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:
[
msdn.microsoft.com]
[
msdn.microsoft.com]
[
support.microsoft.com]
Редактировано 2 раз. Последний раз 30.10.2007 15:10 пользователем Михайленко Илья.