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

Customize PDF Viewer UI & Toolbar with PDF.js Express

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

These PDF.js Express samples show you how to customize the UI, toolbar and menus of our PDF Viewer using APIs.

You can create a simplified UI to match your user’s experience levels or their task requirements by modifying header, enabling/disabling feature sets or hiding individual annotation icons.

You can also import your own colors into your PDF.js Express Web Viewer, and embed custom icons into the toolbar to match your look and feel. View demo.

Below are some code snippets for some common customization use cases.

Change UI theme

WebViewer(
  { ...options },
  document.getElementById('viewer')
).then(instance => {

  // change to dark mode
  instance.UI.setTheme('dark');

  // change to light mode
  instance.UI.setTheme('light');
})

See this guide for more info on custom themes.

Hide/show UI elements

You can use the enableElements and disableElements APIs to hide/show items in the UI.

WebViewer(
  { ...options },
  document.getElementById('viewer')
).then(instance => {

  // disable settings button
  instance.UI.disableElements(['menuButton'])

  // disable search
  instance.UI.disableElements(['searchButton']);

  // disable pan tool
  instance.UI.disableElements(['panToolButton'])
})

See this guide for more information on enabling/disabling elements.

Disable features

We provide an API to disable certain features of the viewer.

WebViewer(
  { ...options },
  document.getElementById('viewer')
).then(instance => {

  // disable printing
  instance.UI.disableFeatures([instance.UI.Feature.Print])

  // disable text selection
  instance.UI.disableFeatures([instance.UI.Feature.TextSelection])

  // disable annotations
  instance.UI.disableFeatures([instance.UI.Feature.Annotations])
})

Add custom buttons to UI

WebViewer(
  { ...options },
  document.getElementById('viewer')
).then(instance => {

  const newButton = {
    type: 'actionButton',
    img: 'path/to/image',
    onClick: () => {
      alert('Hello world!');
    },
    dataElement: 'alertButton',
  }

  // Add a new button that alerts "Hello world!" when clicked
  instance.UI.setHeaderItems((header) => {
    header.push(newButton)
  })

})

See this guide for more information on adding items to the header