472,807 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,807 software developers and data experts.

printing Html without Header and Footer

hi there :)
i ve been looking for some time a way to print an html file from vb.net
i came up with this code for printing and removing the header and footer
from IE
then once the printing is done restore the original header and footer

Imports Microsoft.Win32

Private WithEvents myprocess As Process
Private OldHeader As String
Private OldFooter As String

private sub printhtml()
GetIEHeaderFooter(OldHeader, OldFooter)
SetIEHeaderFooter(" ", " ")
myprocess = New Process
myprocess.StartInfo.FileName = "temp.htm"
myprocess.StartInfo.Verb = "Print"
myprocess.StartInfo.CreateNoWindow = True
myprocess.EnableRaisingEvents = True
myprocess.Start()
end sub

Public Sub SetIEHeaderFooter(ByVal Header As String, ByVal Footer As
String)
Dim strKey As String = "Software\Microsoft\Internet
Explorer\PageSetup"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey,
True)
If Not Header = vbNullString Then
oKey.SetValue("header", Header)
End If

If Not Footer = vbNullString Then
oKey.SetValue("footer", Footer)
End If
oKey.Close()
End Sub

Public Sub GetIEHeaderFooter(ByRef Header As String, ByRef Footer As
String)
Dim strKey As String = "Software\Microsoft\Internet
Explorer\PageSetup"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey,
False)
Header = oKey.GetValue("header")
Footer = oKey.GetValue("footer")
oKey.Close()
End Sub

Private Sub myprocess_Exited(ByVal sender As Object, ByVal e As
System.EventArgs) Handles myprocess.Exited
SetIEHeaderFooter(OldHeader, OldFooter)
End Sub

IE is showing the printing dialog... and the process stops... before i can
press the print button so the original Header and Footer are restored and
printed ... i need to find a way to either remove the printing dialog ... or
find out when to restore the Header/footer so that it doent appear on the
printed page.

( sorry for my english ... hope i m clear enough )

thanx :)
Nov 21 '05 #1
2 9173
mmm anyone have an idea ? i m really stuck :s

thanx :)
Nov 21 '05 #2
up!
it seems that no one knows a way ...
arg ...
"LilBuh" <Li****@discussions.microsoft.com> a écrit dans le message de news:
97**********************************@microsoft.com...
hi there :)
i ve been looking for some time a way to print an html file from vb.net
i came up with this code for printing and removing the header and footer
from IE
then once the printing is done restore the original header and footer

Imports Microsoft.Win32

Private WithEvents myprocess As Process
Private OldHeader As String
Private OldFooter As String

private sub printhtml()
GetIEHeaderFooter(OldHeader, OldFooter)
SetIEHeaderFooter(" ", " ")
myprocess = New Process
myprocess.StartInfo.FileName = "temp.htm"
myprocess.StartInfo.Verb = "Print"
myprocess.StartInfo.CreateNoWindow = True
myprocess.EnableRaisingEvents = True
myprocess.Start()
end sub

Public Sub SetIEHeaderFooter(ByVal Header As String, ByVal Footer As
String)
Dim strKey As String = "Software\Microsoft\Internet
Explorer\PageSetup"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey,
True)
If Not Header = vbNullString Then
oKey.SetValue("header", Header)
End If

If Not Footer = vbNullString Then
oKey.SetValue("footer", Footer)
End If
oKey.Close()
End Sub

Public Sub GetIEHeaderFooter(ByRef Header As String, ByRef Footer As
String)
Dim strKey As String = "Software\Microsoft\Internet
Explorer\PageSetup"
Dim oKey As RegistryKey = Registry.CurrentUser.OpenSubKey(strKey,
False)
Header = oKey.GetValue("header")
Footer = oKey.GetValue("footer")
oKey.Close()
End Sub

Private Sub myprocess_Exited(ByVal sender As Object, ByVal e As
System.EventArgs) Handles myprocess.Exited
SetIEHeaderFooter(OldHeader, OldFooter)
End Sub

IE is showing the printing dialog... and the process stops... before i can
press the print button so the original Header and Footer are restored and
printed ... i need to find a way to either remove the printing dialog ...
or
find out when to restore the Header/footer so that it doent appear on the
printed page.

( sorry for my english ... hope i m clear enough )

thanx :)

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Andrew | last post by:
I am making a web site and I am using ASP because of its templating capabilities. My footer is an include file, for obvious reasons. I can't use an include file for the header, because, while the...
2
by: Dragan Kovac | last post by:
Hello everyone, I have a problem. I generated some kind of my own report (by building HTML file) and now I want to print it. Printing itself is not a problem, problem is with adding custom headers...
5
by: Niyazi | last post by:
Hi, I have an html page and I might be moving to asp.net page that contains a some kind of forum and string. It is kind of application form. User have to enter some (string) value into the...
0
by: LilBuh | last post by:
Hello :) this is a repost... i ve been looking for a way since last week ... i have a template html file that i modify from my code... i need to print this file without IE's Header and Footer or...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
2
by: letsgetsilly | last post by:
I'm developing the external corporate website for my company in Visual Studio 2003 using html, css, and a user web control for the header/navigation. When I try to print any of the pages only the...
2
by: johnb41 | last post by:
I'm using .NET 2.0. My form is displaying the webbrowser control, which is displaying some HTML text. When printing with webbrowser.print(), my printout includes the header and footer. How...
0
by: Andrew Meador | last post by:
I have implemented a printing scenario where an html file is printed using the the following code: public void PrintHtmlFile(string url) { RegistryKey IERegKey; string header = null; string...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.