Bootstrap Icons

PDF LIVE

'PDF LIVE' is a PDF viewer that extends the open source 'mozilla/pdf.js'. You can start the PDF viewer with toolbar right away with 'PDF LIVE'.

npm i pdf-live

Currently v1.0.19 Install Quick Start Usage PDFLiveElement API GitHub repo Changelog

Demo

Quickly start a project from a demo, ranging from partial use of a PDF live to an event or theme.

Light theme

A light theme is a hight-light UI that displays mostly light surfaces.

Dark theme

A dark theme is a low-light UI that displays mostly dark surfaces.

Password protected

If you are working with sensitive information, you need to protect it. Password protect PDFs to prevent unauthorized access.
The correct password for the demo is "password".

Password protection with async listener

Check for correct passwords on the server side.
The correct password for the demo is "password".

Various Events

Demonstration of various PDF Live events.

Install

Install with npm:

npm i pdf-live

Quick Start

CSS

Copy-paste the stylesheet <link> into your <head> to load our CSS.

<link rel="stylesheet" href="node_modules/pdf-live/dist/pdf-live.css">

HTML

Copy-paste the icon <link> into your <head> to load our Favicon.
This step is not required. If you do not wish to set a favicon, skip this step.

<link rel="icon" type="image/svg+xml" href="node_modules/pdf-live/dist/favicon.svg">

Copy-paste the <pdf-live> into your <body> to load our PDF live.

<pdf-live src="sample.pdf" lang="en" worker="node_modules/pdf-live/dist/pdf.worker.js"></pdf-live>

JS

For ES6

To use PDF Live in ES6, simply import the PDF Live ESM module.

<script type="module">
  import './node_modules/pdf-live/dist/pdf-live.esm.js';
</script>
For ES5

To use PDF Live in ES5, please load the UMD module of PDF Live with <script> tag.

<script src="node_modules/pdf-live/dist/pdf-live.js"></script>

Usage

The following example references a PDF live element from within the JS code and sets the event.

// Find the PDFLive node.
const pdflive = document.querySelector('pdf-live');

// Set event listener for PDF Live.
pdflive
  .on('documentLoaded', () => {
    // PDF document loaded.
    console.log('Loaded PDF document');
  })
  .on('pageChange', pageNum => {
    // Page change event.
    console.log(`Opened page ${pageNum}`);
  });

PDFLiveElement API

The PDFLiveElement interface provides special properties and methods for manipulating PDF objects. It also inherits properties and methods of HTMLElement.

EventTarget Node Element HTMLElement PDFLiveElement

Properties

This interface also inherits properties from its ancestors HTMLElement, Element, Node, and EventTarget.

Methods

This interface also inherits methods from its ancestors HTMLElement, Element, Node, and EventTarget.

Events

Inherits methods from its parent, HTMLElement , defined in the GlobalEventHandlers mixin.
Listen to these events using on() or addEventListener().

Changelog

Changelog is available here.