Giter Site home page Giter Site logo

Comments (8)

pipwerks avatar pipwerks commented on July 17, 2024

Hi Janne. Yes, I plan to incorporate pdfViewerEnabled. I've been waiting for it to be more widely supported. Thanks for the reminder, it looks like all the major browser vendors made a big push over the past year to roll out pdfViewerEnabled. Safari iOS finally adopted it in March as part of iOS 16.

There are still plenty of older browsers and OSes that won't support pdfViewerEnabled, so there will need to be conditional logic that falls back to the older approaches when needed.

I don't have an ETA but I'll work on it soon.

from pdfobject.

theodore-s-beers avatar theodore-s-beers commented on July 17, 2024

The logic would look something like this. First, use the pdfViewerEnabled value if there is one. Second, exclude mobile devices. Third, check for a modern browser, PDF.js, etc.

function supportsPDFs() {
  let pdfViewerEnabled = window.navigator.pdfViewerEnabled;

  if (typeof pdfViewerEnabled === "boolean") {
    return pdfViewerEnabled;
  }

  if (isMobileDevice) {
    return false;
  }

  if (isModernBrowser || isFirefoxWithPDFJS || (isIE && supportsPdfActiveX())) {
    return true;
  }

  return false;
}

from pdfobject.

pipwerks avatar pipwerks commented on July 17, 2024

Thanks, yes this is the direction I'm headed. I also plan to refactor to eliminate unnecessary checks/declarations where possible, such as the IE ActiveX check.

from pdfobject.

pipwerks avatar pipwerks commented on July 17, 2024

@jhyot I just uploaded a beta version of 2.3 which has some significant changes, including introducing navigator.pdfViewerEnabled. I've tested against all major browsers, locally and via BrowserStack. Everything works as expected in my tests.

I'd appreciate it if you can check it out and let me know if you encounter any issues. https://pdfobject.com/dev/ and https://github.com/pipwerks/PDFObject/tree/2.3-dev (changes are listed in the 2.3 branch readme). Thanks

from pdfobject.

theodore-s-beers avatar theodore-s-beers commented on July 17, 2024

I haven't done extensive testing, but I read through the recent commits, and it looks good to me. The only problem I noticed (a missing typeof) was already fixed.

from pdfobject.

silverwind avatar silverwind commented on July 17, 2024

Does the mobile browser support change after this? Is there a updated table somewhere which mobile browsers work?

from pdfobject.

pipwerks avatar pipwerks commented on July 17, 2024

Mobile browsers still do not support inline PDFs. https://caniuse.com/pdf-viewer

Safari for iOS displays the first page of a PDF, and without any PDF toolbar, so it's considered a broken implementation.

from pdfobject.

jhyot avatar jhyot commented on July 17, 2024

@jhyot I just uploaded a beta version of 2.3 which has some significant changes, including introducing navigator.pdfViewerEnabled. I've tested against all major browsers, locally and via BrowserStack. Everything works as expected in my tests.

I'd appreciate it if you can check it out and let me know if you encounter any issues. https://pdfobject.com/dev/ and https://github.com/pipwerks/PDFObject/tree/2.3-dev (changes are listed in the 2.3 branch readme). Thanks

@pipwerks I am currently not using PDFObject, so cannot test it (my original question arose during evaluation whether we could use it in future)

from pdfobject.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.