PDF.js in Joomla: multiple JSON profiles

WT PDF.js - Documentation

A catalogue can use config=catalog.json, a mobile layout config=mobile.json, and another section its own file.

Select a profile for a section or iframe

A catalogue can use config=catalog.json, a mobile layout config=mobile.json, and another section its own file. One profile works with both viewers. Multiple iframes may use different file/config values; each window is configured separately.

Switch by building a new URL and assigning iframe.src: the viewer and PDF reload. Editing JSON does not automatically update open tabs. Profiles are fetched on opening with cache: no-store; check independent CDN and Service Worker rules on your site.

JavaScript example

const root = '/joomla'; // '' when Joomla is installed in the domain root
const viewer = new URL(
    root + '/media/plg_system_wtpdfjs/viewer/legacy/web/viewer.html',
    location.origin
);
viewer.searchParams.set('file', root + '/images/documents/catalog.pdf');
viewer.searchParams.set('config', 'mobile.json');
viewer.hash = 'page=2&zoom=page-width';
document.querySelector('#pdf-frame').src = viewer.href;

WebTolk Joomla Extensions

113 Extensions
12 Categories
582 Versions released
893721 Downloads