Install
Grab the package on NPM with:Prepare your DOM
Ensure that your HTML page where you want to use MuPDF WebViewer has a dedicated DOM node available with theid you require, e.g.
Initialization
Once ready you should initialize with initMuPDFWebViewer(). ExampleFile paths to PDFs should be absolute paths.
Optionally set the library path
The main JavaScript viewer libraries will be served from CDN by default, however you can choose to self-host these files by setting thelibraryPath option during initialization.
One of the benefits of self-hosting is that you can reference the files with relative paths from your own domain.
Copy the library assets
The library folder for MuPDF WebViewer is required to be copied to a library path of your choosing.Set the library path during initialization
Then set thelibraryPath option during initialization to point to your chosen path.
Example
File paths to PDFs can be relative or absolute paths if you are self-hosting the library files.
Running
You should be able to run on your local machine’s browser. The following local domains work out of the box:localhost127.0.0.1*.test
Trial License
For local development a license key is not required, however for deployment to production, a license key is required to use MuPDF WebViewer. Visit MuPDF WebViewer to obtain your trial license. Use thelicenseKey option during initialization to set your license key.
Example
When deploying to the web don’t forget that a license key is required & specific to the domain you registered the key against.