## Activities: PDF.js Folder

mod_pdfjsfolder
Maintained by Jonas Nockert
PDF.js Folder is a plugin intended to make sure that added PDFs always open in the browser.
65 sites
19 fans

## 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?

### Awards

• Fri, 6 Dec 2013, 10:04 PM
Many thanks for the kind feedback, Ravi!

About opening in a new window, it's kind of a tricky question as there are different "schools" of thought on the subject.

One perspective is that web pages should leave that choice up to the user. If the user sets the web browser settings to open in tabs, that choice should be respected. If the user shift-clicks a link (in Chrome anyway) the link should open in a new window, etc. Overriding that choice is seen as bad form. Many browsers also default to blocking popup windows or redirect opening new windows to tabs instead.

Another perspective is that users don't always want or need that choice. Some sites actually know better than the user how the material is best presented. Moodle, in general, give teachers options on how to open resources, etc. However, as written above, it's important to know that many browsers and users will override these settings and there is no guarantee that the intention is honored.

I personally prefer the first perspective but Moodle seems to lean to the other. So it seems like I should add the options that other resources provide.

In the meantime, perhaps you can tell your students that they can shift-click or similar on the pdf link (depending on which browser they are using)?

Hope that helps!

Best regards,

Jonas
• Sat, 7 Dec 2013, 11:20 AM
Hi Jonas, Thanks for your detail information.
Thanks again
Ravi
• Fri, 17 Jan 2014, 4:43 PM
Get this error when using Chrome v32. Even in incognito mode.

Working fine in Firefox.
• Mon, 27 Jan 2014, 11:43 PM
Hi Jonas,

I've installed the plugin but still can't seem to use it. When i go to grade the submitted pdf's should i not be able to view from there? Is there perhaps a guide as to how to use it?

Apologies for my lack of knowledge, i'm new to Moodle.

Cian
• Mon, 21 Apr 2014, 12:34 PM
Hi Jonas. I'm using Moodle 2.5. When the new PDF tab opens up, I see just blank dark content. The PDF file loads (I can see my browser making the effor to load it) but does not display. I followed your instructions of renaming the folder as pdfjsfolder and storing it inside the mod folder. What could I be doing wrong? Specifically I am using Moodle 2.5+ (Build: 20130621).
• Tue, 22 Apr 2014, 9:04 AM
Hi Jonas. Any way of amending/tweaking the code so that it is possible to create a folder with no PDF file inside. I would like very much to have an option of creating a folder and then populating it with files...later. Frankie Kam.
• Thu, 24 Apr 2014, 11:01 PM
I've got it working now, thanks. Strange. I actually uninstalled the original folder activity and then installed PDF.js. After that, I reinstalled the folder activity. It works.
• Thu, 24 Apr 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, 16 Oct 2015, 11:48 AM
Hi

Can this plugin be used for Moodle 2.9+?
• Sun, 27 Mar 2016, 12:04 PM
Hmm.. I'd really like to use this module in 3.0 (but it won't install)
• Wed, 6 Apr 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, 11 May 2017, 9:23 PM
Can be used in 3.2.3 with changes of steve.
• Tue, 16 May 2017, 5:05 PM
Can be used in 3.3. With some slight changes, it supports more than PDF´s.
• Tue, 5 Sep 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, 7 Nov 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