Webkit HTMLViewer on Windows (Xojo2021r3.1) no longer loads PDFs

PDFs has being a standard for almost 2 decades, now you can “create” them in xojo, maybe another 2 for the viewer :stuck_out_tongue_winking_eye:

I use the HTMLviewer with Native Renderer and Adobe Reader plugin. Not bullet proof but you can check on the registry if Adobe Reader is installed if not, ask the usser to install it first.

We do have an example already for our MBS Xojo DynaPDF Plugin to show a PDF and allow scrolling through pages.

But we may make a full control for this someday, when DynaForms gets there.

As an alternative you can try to open the file using the system default browser:
Did you try to use system.goToURL( pathToFile ) ? (using URL Path file:///)
https://documentation.xojo.com/api/os/system.html.GotoURL

Or FolderItem.Open to launch the pdf in the system pdf viewer (if any available)
https://documentation.xojo.com/api/files/folderitem.html.Open

Yes, I use those two alternatives in my app for if the user prefers to open things in the default viewer/browser and that’s what I’ve told everyone to do for the time being. Personally, I do think displaying them inside the app is cleaner, with less windows cluttering the screen though.

No, if the URL is local, using the file:// protocol, the same issue occurs

I have tested on Windows 11 Home (virtual machine running via Parallels Desktop 17 on my M1 ARM Macbook) and Windows 10 Home (virtual machine running via Parallels Desktop 16 on my Intel Mackbook). Neither has any PDF software installed, I just use the default of Edge. Two users of my app have reported this issue to me, so I don’t think it is an issue specific to my computers, or at least it’s not a unique thing.

I downloaded, decompressed and ran cefclient.exe. When I type any URL into the address bar and press enter, the “stop” button is enabled for a second, before becoming disabled again, but otherwise there are no other visual changes, nothing is displayed. I have tried, for example

https://google.com

Does this indicate that the problem is with my computer itself? Thanks for taking the time to help me troubleshoot

I didn’t realise that that worked, whenever I’ve tried native renderer, it just asks to download the file rather than display – though I guess I’ve never had Adobe Reader installed. I may have to look into that if I can’t get webkit to work…

Just curious as I did not see it above… Does the Error event on the HTMLViewer fire when you try to load the PDF. and if so, what’s the message property of the exception set to?

Ok, then it would seem that your computer doesn’t like that version of cef for some reason, the last test would be to try their latest version here https://cef-builds.spotifycdn.com/cef_binary_98.1.4%2Bg16dbbdc%2Bchromium-98.0.4758.48_windows64_beta_client.tar.bz2 and see if that works on not. If it works, try each version going backwards until you find where it stops working if you are interested in reading the release notes on that version and possibly finding out what issue fixed it. That will be the edition that Xojo will need to move up to as they might have already solved your issue. If it doesn’t work then you’ll need to contact cef and start reporting the bug to them, I’ve not read up on that. G’luck.

I’m using the Adobe Reader plugin in an HTMLViewer because I display the PDF and also some XML files. But if you are openning just PDFs and want to use the Adobe Reader plugin, HTMLViewer is not even needed, you can use an OLEContainer. It works with local files and also with files on the internet:

AcroPDF.Content.Value("Src") = "https://propofoldreams.files.wordpress.com/2018/03/resp-co2-vent.pdf"

Yeah, that is ridiculos, maybe you can also use the FREE Adobe Reader plugin with the OLEContainer in your app.

No, no Error event fires. I added System.DebugLog to all the HTMLViewer event, and the sequence of event is:

for a HTML page

CancelLoad https://propofoldreams.wordpress.com/
TitleChanged
DocumentBegin https://propofoldreams.wordpress.com/
TitleChanged PROPOFOL DREAMS
https://propofoldreams.wordpress.com/
DocumentComplete https://propofoldreams.wordpress.com/
TitleChanged PROPOFOL DREAMS
TitleChanged PROPOFOL DREAMS
StatusChanged Propofol Dreams – Last Update | PROPOFOL DREAMS

For a PDF:

CancelLoad https://propofoldreams.files.wordpress.com/2018/10/resp-rr-control.pdf
TitleChanged Respiratory | PROPOFOL DREAMS
DocumentBegin https://propofoldreams.files.wordpress.com/2018/10/resp-rr-control.pdf
DocumentComplete https://propofoldreams.files.wordpress.com/2018/10/resp-rr-control.pdf
TitleChanged https://propofoldreams.files.wordpress.com/2018/10/resp-rr-control.pdf
CancelLoad chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html
DocumentBegin chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html
DocumentComplete chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html
TitleChanged chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/index.html

Thanks Julian, I will try this later today when I have time.

Ok, this looks like a promising alternative, thanks!

I need both Mac and Windows and need them both have as close to the same UI as possible for viewing the PDFs.

-Karen

**Alternative - use PDF.js with HTMLViewer - PDF.js is a native cross-platform HTML5 PDF renderer - no software needs to be installed :slight_smile:

1 Like

I’ve just tried the latest version, and after it loads and displays the window, it immediately quits itself. :sleepy:

Another user has just reported the same issue to me so whatever the incompatibility is, it is not that uncommon. Thanks for your help.

I think I will have to give up on webkit HTMLViewer and start looking into the alternatives. Originally, this seemed the best option as it was simple, it worked and it meant I didn’t need to learn how to use and troubleshoot another control – one reason why I haven’t wanted to use a plugin like MBS is that while I’m sure it works well and offers great functionality for advanced users, it looks very intimidating to me and the only function I want is to display a PDF.

I think I’ll look into OLEContainer and ask users to install Adobe Reader. That sounds like it should be future-proof :crossed_fingers: (wishful thinking? :stuck_out_tongue:)

Thanks everyone for your input!

Ok this is embarrassing, but I have been searching for the last 1/2hr. Could someone tell me if I want to use an OLEContainer to control Adobe Reader, what is the ProgramID? I haven’t been able to find any information from Googling :kissing:

AcroPDF.PDF

One last test, does 2021r2.1 still work to show the pdf or have all editions stopped working?

Yes, it still works using 2021r2.1. Using the simple web browser from “Introduction to programming with Xojo”:

Compiling the same app with 2021r3.1:

I thought I would try this, so I installed Adobe Acrobat Reader DC and changed the HTMLViewer to native. Before installing Adobe Reader, trying to load a PDF would result in a download file message box, but now an exception occurs. Well, at least the xojo debugger window is brought to the front and if I look in Runtime → Content, there is an OLEException:

Unknown name, (failed on “queryCommandEnabled”)

and no PDF is displayed.

Thanks Ivan. So next I tried an OLEContainer. I created a new project, added an OLEContainer and in the Opening event put:

Me.ProgramID = "AcroPDF.PDF"

If Me.Create Then
  Me.Content.Value("Src") = "https://propofoldreams.files.wordpress.com/2018/03/resp-co2-vent.pdf"
End If

However it just freezes like this

I think at this point, I need to cut my losses and revert my app back to 2021r2.1 :disappointed:

FWIW surprisingly The HTMLView Can’t seem to displays PDF on the Mac for high Sierra (10.13.6). The app just disappears.

-Karen

I also had problems with debug mode, did you try on a compiled app?

It is Xojo after all… I gues there is a problem with their implementation and the container is not refreshed until it gets an event. Did you try to click on the control?

Xojo wouldn’t be xojo if it didn’t require some hacks. The control not only is refreshed on clicks, it does also on resizing so You can put something like:

OLEContainer1.Width = OLEContainer1.Width +1
OLEContainer1.Width = OLEContainer1.Width -1

after the

OLEContainer1.Content.Value("Src") = ...

I am not web tech savvy. How would one use that in an Xojo PDF Viewer?

-Karen

Try this :slight_smile:

Me.ProgramID = "AcroPDF.PDF"

If Me.Create Then
  Me.Content.Value("Src") = "https://propofoldreams.files.wordpress.com/2018/03/resp-co2-vent.pdf"
End If

me.Refresh(True)

This works :smiley:

Ivan - resize forces a repainting of the screen. Refresh does the same without any hack.

Either this evening or later tomorrow early day… I will throw together a demo and share using PDF.js :slight_smile: Getting ready to wrap up the day at the office here in about 15 minutes now.