HTMLViewer do display PDF on Edge

Using the following code works on all browsers I’ve tested except for Edge. Anyone have any ideas?

wFile = new WebFile
dim pdf as new modGlobal.MyDynapdfMBS
dim f as FolderItem
dim pFileName as String
dim sql as string
dim rs as RecordSet

sql = "SELECT * FROM emp_1095_2 "
sql = sql + “WHERE emp_id = '” + session.strGlobalEmpID + “’”
rs = Session.db.SQLSelect(sql)

#if TargetXojoCloud then
pFileName = “/home/sites/” + Trim(session.strAppFolder) + “/” + rs.Field(“emp_file_name”).StringValue
'pFileName = session.strAppFolder + “” + rs.Field(“emp_file_name”).StringValue
pFileName = rs.Field(“emp_file_name”).StringValue
f = GetFolderItem(pFileName)

if TargetXojoCloud or TargetLinux then
call pdf.AddFontSearchPath “/home/sites/”, true
// on Mac and Windows we use system fonts.
end if

wFile = WebFile.Open(f)
wFile.MIMEType = “application/pdf”

HTMLViewer1.URL = wFile.URL

So, what is the issue?

When the app reaches the last line of code, the app crashes and restarts. But this only happens with the Edge Browser.

Hmm. Try wFile.ForceDownlod=False
right after MIMEType. It’s just a wild guess though :confused:

Not related but, you could alter this code a bit.

sql = "SELECT * FROM emp_1095_2 " sql = sql + "WHERE emp_id = '" + session.strGlobalEmpID + "'"

[code]sql = "SELECT * FROM emp_1095_2 " _

  • “WHERE emp_id = '” + session.strGlobalEmpID+ “’”[/code]

FWIW with a webfile pointing to a PDF file on my disk, this works perfectly with Edge :

dim f as FolderItem = SpecialFolder.Desktop.child("xmetro.pdf") wFile = new WebFile If f <> Nil And f.Exists Then wFile = WebFile.Open(f) // MyFile is a property on the App object wFile.MIMEType = "application/pdf" End If HTMLViewer1.URL = wFile.URL

it’s a hit an miss thing. It works with some users, but crashes with other uses using the same version of Edge. Although I have checked an insider preview of Edge and it seems to be working.

Be aware that the current Windows 10 edge perfectly supports PDF. However, older betas may not. First thing you want to ask your customers is the build number.

Yes I’m aware of that fact, but that doesn’t change the fact that I have several users who are having this problem. What I had to do for a work around is change the line:

HTMLViewer1.URL = wFile.URL


HTMLViewer1.ShowURL (wFile.URL, True)

This forces the PDF to open in a separate Tab.

I was doing something similar yesterday for an app I am developing. Mine is a web app. Edge first blocked the “pop-up” from the “website”. I could not open the new tab before accepting popup windows from the site (ironically, the web app was running on my own computer!)

Some of your users may complain that they canot see the new windows.

[quote=220615:@Jeff Hamby]Using the following code works on all browsers I’ve tested except for Edge. Anyone have any ideas?

Instead of using a Webfile, you may want to generate the PDF file on the accessible web space and make that the URL of the HTMLViewer. If you want to keep the file to the session user only, use a cryptic subfolder name, then remove it and its content when the session ends.