473,480 Members | 1,887 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 9240
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
1764
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
2449
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
5364
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
1883
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
6326
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
3018
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
2625
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
5279
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
6931
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
7032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7076
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.