Printing the contents of a WebHTMLviewer

Is it possible to print the contents of a WebHTMLviewer that was loaded like this:

Var dqt As String = Chr( 34 )
Var head, footer As String
Var bod As String

// Head
head = "<!doctype html> <html lang=" + dqt + "en" + dqt + ">" + _
"<head><meta charset=" + dqt + "utf-8" + dqt + "> " + _
"<title>The HTML5 Herald</title>" + _
"<meta name=" + dqt + "Page Description" + dqt + "content=" + dqt + "The HTML5 Herald" + dqt + ">" 
+ _
"</head>" 

bod = "<body>" 

bod = bod + "<h1>TESTING!</h1>"
bod = bod + "<table>"

bod = bod + "<tr>"
bod = bod + "<td><h4>" + "MUNICIPALIDAD DE ABC" + "</h4></td>"
bod = bod + "</tr>"

bod = bod + "</table>"
bod = bod + "</body>"

footer = "</html>" 

Var html As String
html = head + bod + footer

printHTMLViewer.LoadHTML( html )

Calling the HTMLviewer.print method doesn’t seem to work.

If I load the HTML from a file the .Print method works just fine.

Any thoughts?

Since you have the HTML, many of us use wkHTMLtoPDF to convert it to a PDF ready to print. Alternatively you can write the HTML to a file and open in the default web browser and get the user to print that. Plus I think you can use MBS routines to generate a Picture from an HTMLViewer, then print that.

1 Like

Thanks for your reply David.

I went with the writing to a WebFile solution but will look into creating a PDF.