Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting support for "application/pdf" in Microsoft Edge

Our site tries to detect support for the application/pdf mimetype via a check like this:

function isPdfMimeTypeSupported() {
  if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0)
    for (i = 0; i < navigator.mimeTypes.length; i++) {
      var mtype = navigator.mimeTypes[i];
      if (mtype.type == "application/pdf" && mtype.enabledPlugin)
        return true;
    }
  return false;
}

This works as expected in Chrome however in Microsoft Edge the mimeTypes collection only has two entries:

  • "application/x-shockwave-flash"
  • "application/futuresplash"

The check fails and we are incorrectly warning the user that their browser doesn't support PDF.

If there a way to check for PDF support in JavaScript that works in Edge?

like image 699
Brett Haney Avatar asked Aug 03 '15 17:08

Brett Haney


People also ask

Why PDF is not opening in Edge?

Choose Edge as the Default App for Opening PDF Files To fix it, you should reselect Edge as your default app for opening PDF files. Right-click a PDF file on your computer and go to Open With > Choose another app. Select Microsoft Edge and check the Always use this app to open . pdf files option.

How do I open PDF in Edge app?

Step 1: Open the Microsoft Edge web browser on your Andriod smartphone. Step 3: Select the “Enabled” option from the drop-down list next to the “Trigger Mini App Pdf Viewer” option. Step 4: Restart the browser when prompted as it will allow the changes to take effect.

Can Microsoft Edge fill PDF?

Perhaps one of the biggest improvements on Microsoft Edge is the ability to fill in PDF forms on the web (or locally stored on your device) within the browser, and then save the form for printing. Just open the PDF form, edit the fields and select the options using the drop-down menu as required.

How do I add Microsoft Edge to PDF?

To add a text, open the PDF document in Microsoft Edge 94 (Canary), and click the “Add text” option, as shown in the below screenshot. Or you can also right-click anywhere in the document to add a text box, and then start typing.


2 Answers

Important: The following answer is relevant only for a specific period of time

Microsoft Edge, as suggested above, ships with native PDF viewing support built-in. I don't believe there are any versions of Edge that lack this functionality, but if there are, they would be very rare.

We are currently planning to update navigator.mimeType in the near future, which will cause your present approach (as presented above) to begin working. Until that time, I would encourage you to (I feel terrible for suggesting this) sniff the user-agent string.

This issue will be resolved in a future update to Microsoft Edge.

like image 81
Sampson Avatar answered Oct 06 '22 12:10

Sampson


Check which version of Windows 10 you are using.

If you are using an N edition, then PDF support is not available out-of-the-box, and you'll need to install the Windows 10 Media Feature Pack or Acrobat.

For more information see Windows N editions explained

like image 45
Mark Cooper Avatar answered Oct 06 '22 11:10

Mark Cooper