PDF.js Express Plusplay_arrow

Professional PDF.js Viewing & Annotations - Try for free

side menu

Get Started

play_arrow

Learn more

play_arrow

Common use cases

play_arrow

Open a document

play_arrow

Save a document

play_arrow

Viewer

play_arrow

UI Customization

play_arrow

Annotations

play_arrow

Collaboration

play_arrow

Forms

play_arrow

Signature

play_arrow

Searching

play_arrow

Measurement

play_arrow

Compare

play_arrow

Advanced Capabilities

play_arrow

PDF.js Express REST API

play_arrow

Migration Guides

play_arrow

Changing themes & colors using JavaScript

The following features are available in:

check

PDF.js Express Viewer

help_outline

PDF.js Express Viewer is a free viewer with limited capabilities compared to PDF.js Express Plus

check

PDF.js Express Plus

help_outline

PDF.js Express Plus is a commercial PDF SDK for viewing, annotating, signing, form filling and more

You can change the color theme by either using an API or providing a path to a custom CSS file in the constructor.

Dark theme

Setting WebViewer constructor CSS option

The CSS option allows you to set a css file path while instantiating WebViewer. It's great if you have an external stylesheet file, for example.

Example

WebViewer({
  licenseKey: 'YOUR_LICENSE_KEY',
  path: 'lib',
  css: 'path/to/stylesheet.css'
}, document.getElementById('viewer'));

Using setTheme API

The API allows you to change the theme to another pre-defined theme on the fly. See setTheme for details.

The API allows you to change the theme to another pre-defined theme on the fly. See setTheme for details.

Override CSS variables

Another option is to override CSS color variables. Just like changing the theme, this can be done on the fly (without re-instantiating WebViewer).

Example

WebViewer({
  licenseKey: 'YOUR_LICENSE_KEY',
  path: 'lib',
}, document.getElementById('viewer')).then(instance => {
  const style = instance.iframeWindow.document.documentElement.style;
  style.setProperty(`--primary-button`, 'red');
  style.setProperty(`--primary-button-hover`, 'yellow');
});
WebViewer({
  licenseKey: 'YOUR_LICENSE_KEY',
  path: 'lib',
}, document.getElementById('viewer')).then(instance => {
  const style = instance.UI.iframeWindow.document.documentElement.style;
  style.setProperty(`--primary-button`, 'red');
  style.setProperty(`--primary-button-hover`, 'yellow');
});

You can find the default css variables for both light theme and dark theme in the github repository.

Other properties

See the customizing styles for more information about customizing other properties.