Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

ViewerJS

Security covered Under active development 62 sites

ViewerJS adds a field formatter that previews files without leaving the page. PDFs are rendered with
PDF.js in a sandboxed frame with its own toolbar (page indicator, zoom, fit width,
fullscreen, download, print); JPEG, PNG, GIF and WebP images are shown natively. Other file types get a download link.

Features

  • Works with file and image fields. Choose "ViewerJS" in Manage display.
  • Three modes: overlay (modal dialog), new window, or inline.
  • Private files supported: previews follow Drupal file access.
  • Strict Content-Security-Policy on the viewer frame, no third-party services, works offline.
  • No Libraries module, no jQuery.

Requirements

  • Drupal 10.3 or 11 and the core File module.
  • pdfjs-dist 4.2.67 or newer in libraries/pdfjs-dist
    (see Installation; drush viewerjs:install-library does it for you). Without it PDFs are download-only. The Status report shows whether it is detected.

Installation

  1. Install the module: composer require drupal/viewerjs:^2.0@alpha and enable it.
  2. Install PDF.js: drush viewerjs:install-library. It downloads pdfjs-dist from the npm registry, verifies its checksum and puts it in libraries/pdfjs-dist. Run it again to update PDF.js.

    Without Drush: unpack the pdfjs-dist package into libraries/pdfjs-dist, or, if your site uses asset-packagist, composer require npm-asset/pdfjs-dist.
  3. Check Reports > Status report for the PDF.js entry.
  4. If you installed PDF.js with Composer or by hand, block libraries/pdfjs-dist/web/viewer.html at the web server or delete it. The module does not use it. (The Drush command never installs it.)
  5. In Manage display of a file or image field, choose the "ViewerJS" formatter and pick the preview type (overlay, new window, inline) and size.

Versions

2.0.x (Drupal 10.3+/11) is a complete rewrite and the only supported branch. The 7.x and 8.x branches used the
abandoned ViewerJS library (bundling a 2014 PDF.js with known vulnerabilities) and are no longer supported.
Re-select the formatter when moving to 2.0.x; the color, thumbnail and template settings were removed.

Credits

Preview engine: PDF.js by Mozilla (Apache-2.0).

Ask your assistant about ViewerJS

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Oct 2026
Latest release
11 hours ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core PHP Release date
2.0.0-alpha3 Pre-release 10–11 Oct 26, 2026
2.0.0-alpha2 Pre-release 10–11 Oct 26, 2026
2.0.x-dev Dev 10–11 Oct 26, 2026
2.0.0-alpha1 Pre-release 10–11 Oct 26, 2026