WebViewer Video

WebViewer is a powerful JavaScript-based PDF Library that's part of the PDFTron PDF SDK. It allows you to view and annotate PDF files on your web app with a fully customizable UI.

This is an addon for WebViewer that allows loading HTML5 videos (.mp4, ogg, webm) so that their video frames can be annotated. For more information, see this guide.

Also, try out the react sample here. It shows how to integrate WebViewer and WebViewer-Video with a server component for the saving of annotations.

Demo

https://webviewer-video.web.app/

Initial setup

Before you begin, make sure your development environment includes Node.js and npm.

Install

npm install @pdftron/webviewer-video

How to use

Here is an example of how WebViewer and WebViewer-video could be integrated into your application.

import React, { useRef, useEffect } from 'react';
import WebViewer from '@pdftron/webviewer';
import { initializeVideoViewer, renderControlsToDOM } from '@pdftron/webviewer-video';

const App = () => {
    const viewer = useRef(null);

    useEffect(() => {
      WebViewer(
        {
          path: '/webviewer/lib',
          selectAnnotationOnCreation: true,
        },
        viewer.current,
      ).then(async instance => {
        const license = '---- Insert commercial license key here after purchase ----';

        // Extends WebViewer to allow loading HTML5 videos (.mp4, ogg, webm).
        const {
            loadVideo,
        } = await initializeVideoViewer(
            instance,
            { license },
        );

        // Load a video at a specific url. Can be a local or public link
        // If local it needs to be relative to lib/ui/index.html.
        // Or at the root. (eg '/video.mp4')
        const videoUrl = 'https://pdftron.s3.amazonaws.com/downloads/pl/video/video.mp4';
        loadVideo(videoUrl);
      });
    }, []);

    return (
        <div className="App">
            <div className="webviewer" ref={viewer} />
        </div>
    );
}

export default App;

Also see the React sample, for a complete solution, with further customizations.

Documentation

API documentation

WebViewer APIs

See @pdftron/webviewer API documentation.

License

WebViewer Video will run in trial mode until a license is provided. For more information on licensing, please visit our website.