--***************************
-- CHANGE FOOTER, HEADER, & MARGINS
--***************************
--Changes the Header, footer, & Margin info used when printing from IE
function CHANGEIESETTINGS(Header, Footer, MarginTop, MarginBottom, MarginLeft, MarginRight)
--Get Current Registry Key Values if they exist
IEHeader = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "header", true);
IEFooter = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "footer", true);
IEMarginTop = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_top", true);
IEMarginBottom = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_bottom", true);
IEMarginLeft = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_left", true);
IEMarginRight = Registry.GetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_right", true);
--Set Values based on arguments of function
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "header", Header, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "footer", Footer, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_top", MarginTop, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_bottom", MarginBottom, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_left", MarginLeft, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_right", MarginRight, REG_SZ);
end
--***************************
--Restore Header, Footer, & Margins
--***************************
function RESTOREIESETTINGS()
--Restore User Header, footer, Margin values
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "header", IEHeader, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "footer", IEFooter, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_top", IEMarginTop, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_bottom", IEMarginBottom, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_left", IEMarginLeft, REG_SZ);
Registry.SetValue(HKEY_CURRENT_USER, "Software\\Microsoft\\Internet Explorer\\PageSetup", "margin_right", IEMarginRight, REG_SZ);
end
Here's an example funtion call to change the headers and set margins to .5 inches
-- Change header & footer to "My Custom Header/footer" Change margins to .5 inch
CHANGEIESETTINGS("My Custom Header", "My Custom Footer", "0.50", "0.50", "0.50", "0.50")
Here's the function call to restore the original header, footer, & margins
--Restore User values for Header, Footer, & Margins
RESTOREIESETTINGS()
Also with the web browser control, you can put one on your page as a 1x1 pixel dot (in a corner). Then, you can use your own html templates to create, display, and print pages (like we commonly do with PHP).
1. If you don't want to have the 1x1 pixel Web Browser Object, you can use File.Run to access the M$ Web Browser DLL directly. For example:
Code:
File.Run(_SystemFolder .. "\\rundll32.exe", _SystemFolder .. "\\mshtml.dll,PrintHTML \"" .. _SourceFolder .. "\\AutoPlay\\HTML\\my_page_final.html" .. "\"");
2. If you do use this technique, you can still allow the end-user to choose their printer preference. Simply, include this HTML code at the end of your actual BODY tag in your HTML template:
Code:
onload="window.print();"
3. If all you want to do is print an image (BMP, GIF, JPG, or PNG), with String.Replace just replace [REPLACE_THIS_CONTENT] with an HTML IMG reference to the absolute file path of the image that you want to print. The final HTML would contain something like this:
Code: