JSFiddle - React, Tailwind, and code Playground

by Serghei Cebotari

HTML

<script src="https://cdn.jsdelivr.net/npm/@pdftron/[email protected]"></script>
<div id="viewer" style="width: 100%; height: 100%;"></div>

CSS

html, body {
  height: 100%;
  margin: 0;
}
#viewer {
  height: 100%;
}

JavaScript

WebViewer({
  path: 'lib', // path to the PDFTron 'lib' folder on your server
  initialDoc: 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf' // replace with the URL to the PDF you want to display
}, document.getElementById('viewer'))
.then(instance => {
  // You can now call WebViewer APIs here...
});