• Plugin Author Thomas McMahon

    (@twistermc)


    If you just updated to PDFjs 2.2, and it’s no longer working, there’s a good chance your host needs to add support for JavaScript modules (mjs) files.

    To do this, you can try one of the following.

    • Add AddType application/javascript .mjs to your .htaccess file if you’re on an Apache server.
    • If you’re on a nginx server, open your mime-types.conf.hbs file and update application/x-javascript js; to application/x-javascript js mjs;
    • Contact your hosting support and ask them to add a mime type support for mjs files.

    I’m sorry for the headaches this change is causing. Unfortunately, this plugin is just a wrapper for Mozilla’s PDFjs, and they started using mjs files, which means we have to too.

Viewing 15 replies - 46 through 60 (of 97 total)
  • Plugin Author Thomas McMahon

    (@twistermc)

    Anyone comfortable downloading the plugin from GitHub and testing it out for me? I may have a work around that won’t require people to add support for mjs files to their server.

    https://github.com/TwisterMc/pdfjs-viewer-shortcode/tree/develop

    wp_enthusiast

    (@beeloudglade)

    I don’t have a development site to try, Thomas – sorry. I rolled back to the previous version and it worked fine, but now I’m getting security alerts complaining the plugin needs an update ??

    Burt

    (@burt)

    @twistermc, I tested your develop tree with Firefox/WinX64 on a WP Engine staging environment and ran into this in the browser console:

    Loading module from "https://example.com/wp-content/plugins/pdfjs-viewer-shortcode-master/pdfjs/web/viewer.mjs" was blocked because of a disallowed MIME type ("application/octet-stream"). viewer.php

    I changed references to .mjs to .js on lines 598, 778, and 788 of pdfjs/web/viewer.js and copied pdf.sandbox.mjs to pdf.sandbox.js, and pdf.worker.mjs to pdf.worker.js in the pdfjs/build directory.

    With those changes made, I’m not seeing browser errors, and the PDF is loading as expected. I’m certainly no Javascript expert, and I suspect that there might be some additional changes necessary to enable debugging, but you seem to be on a track that could work.

    Cheers,
    Burt

    Plugin Author Thomas McMahon

    (@twistermc)

    @burt Thank you very much for testing and finding a possible fix. I’ll continue to make updates when I have time.

    For me, adding AddType application/javascript .mjs in .htaccess fixed a bug on Chrome and Firefox.

    On the other hand, I still have a problem on Safari: TypeError: Promise.withResolvers is not a function. (In 'Promise.withResolvers()', 'Promise.withResolvers' is undefined)

    Thank you

    I thought I had a site where it wasn’t working in a couple of browsers. Went and checked the .htaccess file again and for reasons unknown, the line had disappeared. Added it in at the very end and now the problem site is working again. Fingers crossed this gets resolved soon as I have about 20 sites with PDFs where I now need to edit .htaccess.

    • This reply was modified 4 months, 2 weeks ago by paddyd1.

    I have a weird situation related to this:

    I have a Prod and a Dev server.

    In both, I’ve added the “AddType application/javascript .mjs” line to .htaccess.

    This solved my problem on Prod, but did not solve my problem on Dev. On Dev I get a “Forbidden. You don’t have permission to access this resource” error.

    File system permissions on Prod and Dev are identical.

    AND, on Dev, I CAN get directly to a PDF file via its URL.

    So for some reason, this plugin cannot get to it and is throwing an error. Don’t know why!

    I use LiteSpeed Web Server and I added the mime type to my .htaccess file and I added it to the LiteSpeed config and neither allowed PDFjs 2.2 to work.

    I’m kinda late for the party…

    I see people that still can’t get their PDF to show up using the latest version of PDFjs, mostly probably because their Web Browser’s engine don’t support promise.withResolvers

    …and yet I have no problem with the plugin with MIME type configured on one of my hosts, while I do have the problem with the plugin with MIME type configured on another one of my hosts — both while using the same browser.

    Plugin Author Thomas McMahon

    (@twistermc)

    I’m going to release a new version soon (??) that hopefully works without having to make all these mjs updates.

    Plugin Author Thomas McMahon

    (@twistermc)

    @burt I have a new version up on GitHub if you have a moment to test. If not, that’s fine. I think it’s good and plan on releasing soon.

    Plugin Author Thomas McMahon

    (@twistermc)

    @kasugano I hope no one is using IE. Most modern browsers should support promise.withResolvers

    @twistermc Deployed it to the same WPE staging environment, and it loaded PDFs without issue with both Chrome and Firefox on Windows. Good stuff!

    @twistermc Actually, you can get this “problem” when using Waterfox G6.0.17 (Firefox 115.0) or Falkon 24.05.2 (Chrome/118.0.5993.220 via QtWebEngine/6.7.2), which none supports promise.withResolvers.

    But is not a big deal, its for personal use only and the tests should always be done on the mainstream web browsers. o/

Viewing 15 replies - 46 through 60 (of 97 total)
  • You must be logged in to reply to this topic.