PDF.js Folder

Activities ::: mod_pdfjsfolder
Maintained by Jonas Nockert
PDF.js Folder is a plugin intended to make sure that added PDFs always open in the browser.
Latest release:
66 sites
30 fans
Moodle 2.4, 2.5, 2.6

How PDFs are opened in browsers seem to depend on many things, like which browser the user is using, the configuration of PDF readers and which operating system is being used. To a smaller degree, it depends on the settings in Moodle.

In most cases, the handling of PDFs should be left under the control of the user but in some cases there are valid reasons to try to standardize the experience.

Pdfjsfolder is a Moodle 2.4+ plugin intended to make sure that PDFs always open in the browser (with the option of downloading), regardless of if the user is using a desktop or mobile device.

Pdfjsfolder is built on PDF.js:

  • PDF.js is Portable Document Format (PDF) viewer that is built with HTML5.
  • PDF.js is community-driven and supported by Mozilla Labs. Our goal is to create a general-purpose, web standards-based platform for parsing and rendering PDFs.
  • PDF.js will not work in all browsers, most notably IE8 and below.
  • PDF.js, at the moment, performs rather poorly on mobile devices with limited memory and processing power (which covers almost all devices out there, new and old). Some PDFs are fine but others are too big, to complex, contain too many images, etc. Your mileage may vary.

Pdfjsfolder works much like the regular folder resource in Moodle and handles images as well as PDFs (for practical reasons). Zip files can be uploaded and unpacked.

There are a few options:

  • Should PDFs open in the current tab/window or open in a new tab/window?
  • Should folder contents be shown inline on the course page or on a separate page?
  • Should subfolders be shown expanded or not?
  • Should an alternative download link be displayed for each PDF so that users with devices not capable of displaying all PDFs through PDF.js have another option?


Screenshot #0
Screenshot #1


Jonas Nockert (Lead maintainer)
Please login to view contributors details and/or to contact them

Comments RSS

Show comments
  • Frankie's the name, Moodle's my game!
    Thu, Apr 24, 2014, 11:06 PM
    Hi Jonas. Actually I think that it would be better to have a window pop up with the choice to Open In A New Tab, Save as File, or Download immediately. If Open In A New Tab is chosen, as the new tab is opened, and the PDF file is being downloaded, a message "Loading file" should be shown so that the user knows that something is happening. This is especially so when the PDF file is large in size and the loading into a new tab takes some time. At the moment, as it is programmed, the PDF file in the tab takes some time to load up and the user is left staring at a mainly black screen wondering if the system hung or not. Just some suggestions of mine.
  • Fri, Oct 16, 2015, 11:48 AM

    Can this plugin be used for Moodle 2.9+?
  • Sun, Mar 27, 2016, 12:04 PM
    Hmm.. I'd really like to use this module in 3.0 (but it won't install)
  • Wed, Apr 6, 2016, 9:54 PM
    Paul, try changing the $module entries in version.php to $plugin which means it will be 'seen' by Moodle 3. Seems to work fine for me.
  • Thu, May 11, 2017, 9:23 PM
    Can be used in 3.2.3 with changes of steve.
  • Tue, May 16, 2017, 5:05 PM
    Can be used in 3.3. With some slight changes, it supports more than PDF´s.
  • Tue, Sep 5, 2017, 7:10 PM
    Can I confirm - we use the module with modifications under moodle3.3.1
    in addition we have restricted pdfjs - no save, no print, no copy
  • Tue, Nov 7, 2017, 2:54 AM
    i did everything you suggested and now i have this : Coding error detected, it must be fixed by a programmer: cm_info::get_custom_data() can not be used anymore. Please use the property cm_info->customdata instead
  • Thu, Oct 31, 2019, 11:16 AM
    If still interesting need change $cm->get_custom_data() on $cm->customdata in 436 and 451 strings in file pdfjsfolder/lib.php
    It's worked on my Moodle 3.7.2+ (Build: 20191025)
  • Wed, Dec 18, 2019, 4:10 PM
    [Error] Unsupported syntax detected in version.php file [$module]
    Installation aborted due to validation failure,
  • Sun, Dec 22, 2019, 12:46 AM
    [Error] Unsupported syntax detected in version.php file [$module]
    Installation aborted due to validation failure,
    What to do?
  • Sat, Feb 22, 2020, 3:45 PM
    Does somebody reply here?
  • Thu, May 7, 2020, 8:54 PM
    For Moodle 3.8, I was successful to install this plugin with the following modifications:

    --- mod/pdfjsfolder/version.php.orig 2020-05-07 16:30:28.370170868 +0900
    +++ mod/pdfjsfolder/version.php 2020-05-07 16:30:50.806427814 +0900
    @@ -27,9 +27,9 @@

    defined('MOODLE_INTERNAL') || die();

    -$module->version = 2013120300;
    -$module->requires = 2012120300;
    -$module->cron = 0;
    -$module->component = 'mod_pdfjsfolder';
    -$module->maturity = MATURITY_BETA;
    -$module->release = '0.14';
    +$plugin->version = 2013120300;
    +$plugin->requires = 2012120300;
    +$plugin->cron = 0;
    +$plugin->component = 'mod_pdfjsfolder';
    +$plugin->maturity = MATURITY_BETA;
    +$plugin->release = '0.14';

    --- mod/pdfjsfolder/lib.php.orig 2020-05-07 16:35:25.249570732 +0900
    +++ mod/pdfjsfolder/lib.php 2020-05-07 21:50:38.558981806 +0900
    @@ -433,7 +433,7 @@
    function pdfjsfolder_cm_info_dynamic(cm_info $cm) {
    // The field 'customdata' is filled in only if folder is to be
    // shown inline.
    - if ($cm->get_custom_data()) {
    + if ($cm->customdata) {
    @@ -448,7 +448,7 @@
    global $PAGE, $DB;

    if ($cm->uservisible &&
    - $cm->get_custom_data() &&
    + $cm->customdata &&
    has_capability('mod/pdfjsfolder:view', $cm->context)) {
    require_once(dirname(__FILE__) . '/locallib.php');
  • Fri, Jun 26, 2020, 10:56 PM
    > For Moodle 3.8, I was successful to install this plugin with the following modifications:

    I received a message that says my post is not clear, so I rewrite the post to show how you should modify the pdf.js files:

    In version.php under mod/pdfjsfolder/ , find the lines like

    $module->version = 2013120300;
    $module->requires = 2012120300;
    $module->cron = 0;
    $module->component = 'mod_pdfjsfolder';
    $module->maturity = MATURITY_BETA;
    $module->release = '0.14';

    and modify them to

    $plugin->version = 2013120300;
    $plugin->requires = 2012120300;
    $plugin->cron = 0;
    $plugin->component = 'mod_pdfjsfolder';
    $plugin->maturity = MATURITY_BETA;
    $plugin->release = '0.14';

    In lib.php under mod/pdfjsfolder/ , find the line like

    if ($cm->get_custom_data()) {

    and modify it to

    if ($cm->customdata) {

    and also find the line like

    $cm->get_custom_data() &&

    and modify it to

    $cm->customdata &&

    That is all you have to do to make PDF.js Folder installable.
  • Mon, Feb 1, 2021, 1:28 PM
    I managed to change some code with the latest Moodle standards, and the plugin works for Moodle 3.10+
    You can download it on my github onyet/onyetmpdf
1 2
Please login to post comments