PDF.js in Joomla: choose and load a library

WT PDF.js - Documentation

This works in a frontend module layout, component view or template override.

Choose a PDF.js build for a Joomla page

This works in a frontend module layout, component view or template override. Keep one library activation per window: multiple builds may replace the global object and worker settings. Each iframe creates its own window, so its viewer works independently.

Use globalThis.pdfjsLib after module execution. Initializers set GlobalWorkerOptions.workerSrc. A worker script tag does not enable background processing; PDF.js creates its worker from that configured URL.

PHP example

<?php
use Joomla\CMS\Factory;
$document = Factory::getApplication()->getDocument();
$wa = $document->getWebAssetManager();
// Choose ONE build for this page.
$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, newer browsers

WebTolk Joomla Extensions

113 Extensions
12 Categories
582 Versions released
893721 Downloads