Please advice me (:

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Moore (rainman_cool_at_yahoo.com)
Date: 01/27/05


Date: 27 Jan 2005 13:39:40 -0800

Hi all,

I am trying to create HTML file and print it automatically, which was
possible with the below code...but somehow, it is printing with all
<HTML> tags...could somebody tell me , how to print the HTML file
without , all those HTML tags...??

Please help me...(:

- Moore

======
Dim temp as streamreader = New
StreamReader("C:\Inetpub\wwwroot\test.html")
Dim prntFont as Font = New Font("Arial", 10)

Dim pd As New PrintDocument
AddHandler pd.PrintPage, New
System.Drawing.Printing.PrintPageEventHandler(AddressOf
Me.pd_PrintPage)
pd.PrinterSettings.PrinterName = printername
If pd.PrinterSettings.IsValid Then
pd.Print()
End If

=======
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As
System.Drawing.Printing.PrintPageEventArgs)

Dim lpp As Single = 0
Dim yPos As Single = 0
Dim count As Integer = 0
Dim leftMargin As Single = ev.MarginBounds.Left
Dim topMargin As Single = ev.MarginBounds.Top
Dim line As String = Nothing

'Work out the number of lines per page
'Use the MarginBounds on the event to do this
lpp = ev.MarginBounds.Height / prntFont.GetHeight(ev.Graphics)

line = stringToPrint.ReadToEnd

While (count < lpp And line <> Nothing)

yPos = topMargin + (count * prntFont.GetHeight(ev.Graphics))

ev.Graphics.DrawString(line, prntFont, Brushes.Black, leftMargin, yPos,
New StringFormat)

count = count + 1

If (count < lpp) Then
line = temp.ReadToEnd
End If

End While

'If we have more lines then print another page
If (line <> Nothing) Then
ev.HasMorePages = True
Else
ev.HasMorePages = False
End If

End Sub
=====

rider_2004
View Public Profile
Send a private message to rider_2004
Find More Posts by rider_2004
Add rider_2004 to Your Buddy List



Relevant Pages

  • Re: DOM manipulation crashes with IPersistStreamInit
    ... Public Function GetHTMLDocument_WebRequest(ByVal sURL As String) As ... Dim oResponse As WebResponse ... 'Request the HTML file and read the response into a string ... And SUCCESS!! ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: VBA macro not scanning entire Inbox
    ... Instead, use a down-counting loop: ... certain string, and if it finds the string, it extracts a job number ... Dim Inbox As Outlook.MAPIFolder ... 'This section also adds an entry into the html file for each message that is ...
    (microsoft.public.office.developer.outlook.vba)
  • Re: Generating HTML from VB 6.0
    ... > I have been told that I can generate an HTML file from VB 6.0, ... Private Sub CreateHTML() ... Dim sTxt As String ... Dim sFile As String ...
    (microsoft.public.vb.general.discussion)
  • Re: How to link the image files on internet?
    ... not found" html file will be download and saved as JPG. ... How can I know the downloaded file is JPG, but not the "404" html file? ... > Public Function DownloadPicture(ByVal strURL As String) As String ... > Dim xmlhttp As Object ...
    (microsoft.public.access.modulesdaovba)
  • Paste HTML containing complex table into Excel
    ... My VB.NET application produces some calculations and generates a HTML file ... Dim sr As System.IO.StreamReader = Nothing ... Or should I used some other technology for exporting, t.i., another objects ...
    (microsoft.public.dotnet.languages.vb)