HTMLViewer printing

I’m just starting my first web project so this could well be my misunderstanding - I have an HTMLViewer on my page “htmlSlip” and I have a print button. The print button simply calls htmlSlip.Print. My printout displays the browser window and not the HTMLViewer content. Bug or ignorance?

Win 7, 2013 r3

Bump. Any direction?

[quote=36940:@Peter Fargo]I’m just starting my first web project so this could well be my misunderstanding - I have an HTMLViewer on my page “htmlSlip” and I have a print button. The print button simply calls htmlSlip.Print. My printout displays the browser window and not the HTMLViewer content. Bug or ignorance?

Win 7, 2013 r3[/quote]
It does say that it prints out the page in the documentation. Whether this is a bug or bad documentation, there is something that needs fixing and you should definatly make a feedback report. http://documentation.xojo.com/index.php/HTMLViewer.Print

The docs did confuse me. The top states it prints the contents of the htmlviewer and lower down in the example it states it prints the current page.

The User’s Guide (Framework) says it can be used to print the content of the viewer.

Feedback submitted.

Unfortunately it depends on the browser. When this feature was implemented, it worked correctly on all supported browsers, but now not so much. We’ll have to test them again and see what we can do about it.

Thanks Greg. I’ll explore options until then.

Greg, any further news on this? It’s driving me mad… Printing anything from a web app is a nightmare, but thought I had cracked it with HTMLViewer.Print

Works great in all browsers except Explorer! I know it’s not really a Xojo fault, but we really need a solution…

Did you guys fill a feedback case, so we can track progress?

this is a big problem for us also; as someone already stated, printing from
a xojo web app is really a nightmare. I thought I had all my client’s problems
solved when I started using the htmlviewer to do the printing for me, but now
they’re complaining (and rightly so) that it doesn’t work properly with IE.

what are we supposed to tell our clients? don’t print from internet explorer??

please help - workaround? anything?

Either you make a special webview and people print the webpage or you download a PDF which people can print.

Most every web site I know of creates a new window for print, and uses the JavaScript Window.Print http://www.w3schools.com/jsref/met_win_print.asp to print that window.

Alternatively or in complement, you can instruct the user to press Ctrl-P.

see also
https://www.mbsplugins.de/archive/2011-03-01/Tip_of_the_day_Hide_button_on_

Christian:

thanks for your responses.

I’ve created a separate web page for printing, and tried placing the report data
in a page-source object; this only displays and prints data that falls within the
height setting of the page. I can’t say how many pages of data the user might
need to print, but being constrained by the height of the webpage makes this
method unusable for me - unless I’m missing something…

could you elaborate on how one would create a pdf from within a xojo web
application?

thank you.
rm.

you can download MBS Plugins and check web examples for DynaPDF.

Ok, I haven’t tried this on all versions of all browsers but it works with IE11:

[code]Sub PrintHTMLViewer(ThisHTMLViewer As WebHTMLViewer)
’ ----------------------------------------------------------------------
’ Procedure Name: PrintHTMLViewer
’ Notes
’ IE prints the whole page not just the viewer so do a bit of javascript
’ to just print the HTMLViewer for IE
’ ----------------------------------------------------------------------

Select Case Session.Browser

Case WebSession.BrowserType.InternetExplorer

Dim s() As String
Dim sJavascript As String

s.Append("var thisObject = document.getElementById('{ControlId}');")
s.Append("var list = thisObject.getElementsByTagName('iframe');")
s.Append("var thisiFrame = list[0];")
s.Append("thisiFrame.contentWindow.focus();")
s.Append("thisiFrame.contentWindow.print();")

sJavascript = Join(s, " ")

sJavascript = Replace(sJavascript, "{ControlId}", ThisHTMLViewer.ControlId)

ThisHTMLViewer.ExecuteJavaScript (sJavascript)

Case Else

' Simply Print the viewer!
ThisHTMLViewer.Print

End Select
End Sub
[/code]