WT PDF.js
- Categories: Joomla plugins, Web Assets
- Version: 6.4.299
- Date:
A general-purpose, web standards-based platform for parsing and rendering PDFs.
Description
WT PDF.js is a system plugin for Joomla 5 and later that registers PDF.js in WebAssetManager. Use it in PDF-enabled modules, components and template overrides.
- Local PDF.js 6.4.299 libraries for newer and older browsers.
- A CDN latest asset that automatically selects a worker with the matching version.
- Two complete web viewers, opened through a link or embedded in an iframe.
- User JSON profiles for theme, zoom, language, sidebar and PDF loading settings.
- Configuration files are stored separately and survive plugin updates.
The plugin supplies the library and viewers; your extension integrates them and displays PDFs. The installer requires PHP 8.1 or later; your Joomla version requirements must also be met.
How to use?
Plugin for Joomla developers. It allows you to use PDF.js anywhere in Joomla 5+: in modules, components, plugins.
Activate the appropriate asset in your code:
<?php
use Joomla\CMS\Factory;
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();
$wa->useScript('wt-pdf-js'); // Local: newer browsers
// $wa->useScript('wt-pdf-js-legacy'); // Local: older browsers
// $wa->useScript('wt-pdf-js-latest'); // CDN latest; choose ONE build
Configuring MIME types on the server for *.MJS-files
Servers often do not have MIME types configured for files with *.mjs extensions. Therefore, the browser may not understand that this is actually javascript code and you may see an error in the browser console pdf.mjs:1 Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.
To solve this problem, you either need to ask the hosting company's technical support to configure MIME types for mjs files. Or do it yourself:
1. Make sure that the Apache module mod_mime is installed and enabled on the server.
2. Add the following code to the end of your .htaccess:
<IfModule mod_mime.c>
AddType text/javascript mjs
</IfModule>
Joomla
- Extension type:
- Plugin
- Folder:
- System
- Joomla version:
- 5.2.3, 5.3.3, 6.1.4