WebHTMLViewer: can't display a PDF inside


I have been working with Xojo for about a month an a half, creating demos. I always solved issues but this time, I can’t figure out.

Xojo version: 2018 R1.1

OS: Windows 10 1709 full patched

Type of application: Web

When the user do a selection in a list, the corresponding PDF should be displayed in a WebHTMLViewer. This viewer is inside a WebContainer, and this WebContainer is on my WebPage.

Everything, well almost, works. I get the PDF from a FileMaker database and is stored in a WebFile which is a property of the WebPage. When I set the WebHTLMLViewer URL to that of the WebFile, nothing happens, the PDF is not displayed at all. I tried adding a new WebHTMLViewer right on the WebPage, sams issue. But If I call ShowURL in a new page, the the browser opens a new tab and display correctly the PDF.

Here is the final code:

[code]Dim conn As New FM_connection
Dim strData As String

’ On va chercher le pdf

’ Gets the PDF file from the database and loads it in a WebFile (property of WebPage1)


If WebPage1.PDFWebFile <> Nil Then

WebPage1.PDFWebFile.FileName = “Fichier.pdf”
WebPage1.PDFWebFile.MIMEType = “application/pdf”

’ The WebHTMLViewer URL is set to that of the WebFile

Me.WP1HTMLViewer.URL = WebPage1.PDFWebFile.URL ’ The content of the WebHTMLVIewer is not changed

Me.WP1HTMLViewer.SetFocus ’ tried this to see if that would help

ShowURL(WebPage1.PDFWebFile.URL, True) ’ Tada, the PDF is displayed, not where I wishes though

strData = WebPage1.PDFWebFile.Data

End If[/code]

I tested inside FreFox.

Just what am I doing wrong ???

Many thanks

Unless you view your app in Chrome or Edge, PDF support in other browsers is really minimal.

@Michel Bujardet

As far as I understand, the HTMLWebViewer will use the plug-in from the default Web Browser to display a PDF, right ? If this true, since FireFox displays the PDF right in a tab, how come the HTMLWebViewer can’t ? On top of that, that works quite well in another prototype I created, just simpler than this one.

So the $ 1,000,000 question: is there some way to have a WebHTMLViewer display a PDF independently of the default browser ? That would be perfect. I am surprised it’s so complicated to display a PDF in a Web Browser in 2018. Web applications are not near to replace good old desktop applications.

Technically, WebHTMLViewer is an iframe. I am not so sure the plugin knows how display a PDF in that case.

You may try to replace the direct URL to the WebHTMLViewer by a skeleton HTML page. It could help the plugin do it’s job.

Something like



Use replace to put the URL in place of the star. Then display the HTML in with loadpage.

The million dollars question answer is : if you can use jpg, png or gif, it will display just fine in any Windows browser without any plugin. Especially Internet Explorer which is still extremely frequent.

New tests were done, and it points in another direction. So I created a new thread https://forum.xojo.com/48503-can-an-event-handler-call-a-method-on-anotther-object

Have you even tried the method I suggested with an HTML page ? Your new thread does not seem to bring anything new.

No I haven’t tried using your suggestion. You suggest img src=something> But what I have is a PDF file whose contents is in a string variable (I got it base64 encoded)). I don’t get how the base html code may help.

The other thread explains the road to the issue, so the question in the other thread is “in an event routine, is it possible to invoke another object’s method with success ?”.

The issue has been solved, see the other post.

My conclusion is developing for the Web “seems” like developing for the desktop, but it’s not at all. Where can I get a good documentation on how to develop for Web in Xojo ? And I mean documentation with full explanation and working code, not incomplete code snippet.


This forum would be a good place to get help from people who have a very solid background in Xojo Web, JavaScript, HTML and CSS. At the condition to really work with them.