Results 1 to 2 of 2

Thread: [2005] Printing HTML

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2006
    Posts
    182

    [2005] Printing HTML

    I'm trying to find a new method or a fix of my current method to print out an HTML page. At the moment I think the script is loading too fast and it is not writing the html to the file. If i put a msgbox between the variable and the writing to the file it works fine. So it seems i need some sort of a pause?? Any ideas or alternative methods?
    Do I need any imports or anything at the top?

    Code:
                    WebBrowser1.Navigate(New System.Uri("about:blank"))
                    Dim MyHTML As String
                    MyHTML = ""
                    MyHTML = "<HTML><HEAD>" & vbCrLf & _
                    "<TITLE>Test Print</TITLE>" & vbCrLf & _
                    "</HEAD>" & vbCrLf & _
                    "<BODY topmargin=0 leftmargin=0 rightmargin=0 bottommargin=0 marginwidth=0 marginheight=0>" & vbCrLf & _
                    "<div align=left>" & vbCrLf & _
                    "<table border=0 width=360 id=table1 cellspacing=0 cellpadding=0 align=center>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=100% colspan=2><font face=Verdana size=3><b>Preview Services UK</b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Priority " & rmPriority & "</font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td bgcolor=#000000 width=35%><b><font color=#FFFFFF face=Verdana size=1>RM JOB ID:</font></b></td>" & vbCrLf & _
                    "<td rowspan=8><p align=center><br><br><font face='IDAutomationHC39M' size='4'>*" & TextBox1.Text & "*</font><br><br><b><font face='Verdana' size='6'>" & rmPriority & "</font></b></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35%><font face=Verdana size=1>" & TextBox1.Text & "</font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35% bgcolor=#000000><b><font color=#FFFFFF face=Verdana size=1>PACKET ID:</font></b></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35%><font size=1 face=Verdana>" & rmScannedPacketID & "</font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35% bgcolor=#000000><font color=#FFFFFF face=Verdana size=1><b>DATE:</b></font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35%><font size=1 face=Verdana>" & Now & "</font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35% bgcolor=#000000><font color=#FFFFFF face=Verdana size=1><b>PRINTED BY:</b></font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td width=35%><p align=left><font size=1 face=Verdana>" & TextBox2.Text & "</font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td colspan=2 width=100%><hr align=center></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "<tr>" & vbCrLf & _
                    "<td colspan=2><p align=left><font size=0.5 face=Verdana><i>www.previewservices.co.uk</i></font></td>" & vbCrLf & _
                    "</tr>" & vbCrLf & _
                    "</table>" & vbCrLf & _
                    "</BODY>" & vbCrLf & _
                    "</HTML>"
    
                    MsgBox("Please be patient, the print dialog will appear shortly", MsgBoxStyle.Information)
    
                    WebBrowser1.Document.DomDocument.Write(MyHTML)
                    System.Windows.Forms.Application.DoEvents()
    Cheers,
    Ross
    Last edited by Ross_m; Apr 11th, 2007 at 11:12 AM.

  2. #2
    Fanatic Member bgmacaw's Avatar
    Join Date
    Mar 2007
    Location
    Atlanta, GA USA
    Posts
    524

    Re: [2005] Printing HTML

    Wait until it is completely loaded.

    vb Code:
    1. Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
    2.      Application.DoEvents()
    3. Loop

    You may want to add time out code and further exception management to this example.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width