How to force HTMLViewer to use Preview plugin

Hi

My app crashes if Adobe Acrobat Reader DC is installed on Mac, anytime when a htmlviewer is loading a PDF file. This is due to the two adobe internet pdfviewer plugins which are saved in the Internet plugins folder of the Mac. If I delete those plugins, my app works fine.

How can I force the HTMLViewer not to use the Adobe plugins for the HTMLViewer on Mac?

Thanks.

Indeed, Apple has removed support for NPAPI plugins (which are used by Adobe) with the latest macOS update. The plugins remain installed and crash if it is used as well as your app.
I do not know if it is possible to force the use of ‘Preview’ in an HTMLViewer, but you can check with a javascript if Adobe plugins are installed to avoid loading a PDF.

Load this page in the HTMLViewer and check the ‘StatusChanged’ for InStr(newStatus,"navigator.plugins:Adobe Acrobat")>0

[code]

[/code]

Just a few days I blogged about it: Adobe PDFViewer crashes in FileMaker

So maybe in Xojo, you can also just throw it to the trash.

or did you check WebPreferencesMBS in MBS Xojo Plugins and set arePlugInsEnabled to false?

Hi @Alain Clausen
In which event handler do I have to load that HTML code? And what are the instructions that follow if the INSTR is not 0?

I suppose StatusChanged Event…

Then all is OK (I suppose too).

You can do this test when opening the HTMLViewer (or window) and save the result (Adobe installed YES/NO) in a global variable.
The code listed above lists all plugins installed via the ‘StatusChanged’ event of the HTMLViewer. You can also directly modify the javascript to indicate only the status for Adobe.
In the following example the value of ‘newStatus’ contains either “Adobe.plugins:Not found” if the plugins are not detected, or “Adobe.plugins: Installed” if they are installed.

[code]

[/code]

Depending on the result you can open PDFs in HTMLViewer or indicate the procedure to remove Adobe plugins …

I did something like this:

If Volume(0).Child("Library").Child("Internet Plug-Ins").Child("AdobePDFViewer.plugin").Exists _ Or Volume(0).Child("Library").Child("Internet Plug-Ins").Child("AdobePDFViewerNPAPI.plugin").Exists Then adobeDelete End If

adobeDelete is an Applescript which is this:

set libraryFolder to path to library folder
tell application “Finder”
delete (every item of folder “Internet Plug-Ins” of libraryFolder whose name starts with “AdobePDFViewer”)
end tell

Instead of Volume(0).Child(“Library”) use SpecialFolder.Library.

If need to check for every child if the folder isn’t nil and exists.

Don’t use an AppleScript except if you really have to because of the wonderful permissions in Mojave.

@Beatrix Willius The only way I found is to tell Finder to delete those files, because it does not go without prompting for password. That’s why I used AppleScript. Now if, as you say about Mojave, the user does not give his permission, then it won’t work. In that case I execute a shell command: “tccutil reset AppleEvents” on Mojave and “tccutil reset AppleEvents (bundle name of app)” on Catalina. This causes that the user will be asked again for permission when he starts my app.

Agree with Beatrix here, Catalina changes some system paths, so hard coded ones are likely to fail.

There are other ways to delete files with permission and not using Apple Script; some Googling should help you find them.

You should also sign on to this feature request; as it’s asking Xojo to update the HTMLViewer to the newer replacement. <https://xojo.com/issue/52330>

I can‘t test right now, but regarding permission and no AppleScript: would that work, too?
@Payam Arzani : please don‘t tccutil reset AppleEvents for all applications… I wouldn‘t like that if an app does that without asking.

@Jürg Otter ok I will remove that for Mojave.

From what I can see, this command requires the user to be an administrator and since it’s in the security & privacy category, will probably require a password to actually work. Have you checked the exit code on a non-dev machine?

Hi
I don’t know what you mean by exit code. I tried the tccutil on two computers and it didn’t require any password, and on the Privacy tab, the Automation list was empty after I executed that command on Mojave, and on Catalina, since I specified the bundle name, it only deleted my app from the Automation list. Of course, if you are no administrator, then you always need to enter the password for anything of this sort, even as you need to do that when you simply want to install something.