Run the samples

In this document
chevron_rightRun on dev server

You can view live WebViewer samples for Universal and PDFNetJS but they can also be run locally from your development server.

Run on dev server

The samples are included in the latest WebViewer download package.

  1. Unzip the download package and copy the unzipped folder to your server.

  2. Find the samples-key.js file and replace the empty string with your license key.

    window.sampleL = 'YOUR_LICENSE_KEY_HERE';
  3. Assuming you've copied it to the root of your server you can navigate to it, for example if you're on port 8000 localhost:8000/WebViewer/samples.html.

    • If you don't already have a local dev server this MDN guide shows how to set one up.
    • You will not be able to run the samples from the file system (for example double clicking samples.html) because of browser security restrictions.
  4. Use the buttons at the top of the page to toggle between PDF/Office samples and XOD (Universal) samples. Most of the samples are the same but there are a few PDF specific samples and a few XOD specific ones.

  5. Click on any of the sample links to run them in the browser.

All of the code for each sample is found in the samples folder if you want to inspect or modify it.

Be aware of cross origin restrictions
If you try to load a file from a URL in the basic sample this may fail if the server that the file is on doesn't have proper cross origin headers set.

If you see an error in the console mentioning No 'Access-Control-Allow-Origin' header is present on the requested resource then this is the cause of the issue and you should try copying the file to your server to successfully load it.