HTMLViewer on WebApp

This code works fine on desktop app

Var f As FolderItem = SpecialFolder.SharedDocuments.child("test.pdf")
DocViewer.LoadURL(f.URLPath)
Label4.Text = f.AbsolutePath

DocViewer is an DesktopHTMLViewer on desktop app and a WebHTMLViewer on web app version. In other version label4 display the same file url : Macintosh HD:Users:Shared:test.pdf

This file exist and it’s present in the desktop app but not on the web app …

Any idea ?

Try something like this:

Var f As FolderItem = SpecialFolder.SharedDocuments.child("test.pdf")
Var webf as WebFile = WebFile.Open(f) //Might need to define webf as a property of the WebPage
DocViewer.LoadURL(webf.URL)

I define webF as page property

Unfortunately the code now download the file not display it on the HTMLViewer…

// Because we want to display the PDF file in an HTMLViewer
// set the ForceDownload property back to False
webf.ForceDownload = False

You can try this. webf property is a WebFile.

I try

Var f As FolderItem = SpecialFolder.SharedDocuments.child("test.pdf")
webf = WebFile.Open(f)
webf.ForceDownload = False
DocViewer.LoadURL(webf.URL)
Label4.Text =webf.URL

My test file is not displayed on the htmlviewer, it still downloaded by this line

DocViewer.LoadURL(webf.URL)

I found what I miss

webf.MIMEType = “application/pdf”

Final code:

Var f As FolderItem = SpecialFolder.SharedDocuments.child("test.pdf")
webf = WebFile.Open(f)
webf.MIMEType = "application/pdf"
DocViewer.LoadURL(webf.URL)
Label4.Text =webf.URL

Thank you everybody

More informations was founded here:

Yeah, that one! :wink:

I thought you was getting rid already of the MIME type :slight_smile:

1 Like