Skip to content

Instantly share code, notes, and snippets.

@FrancescoBonizzi
Created November 28, 2021 13:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FrancescoBonizzi/e0c2313806170ef32b62fde2a2fc2d39 to your computer and use it in GitHub Desktop.
Save FrancescoBonizzi/e0c2313806170ef32b62fde2a2fc2d39 to your computer and use it in GitHub Desktop.
<script>
document.addEventListener('DOMContentLoaded', function () {
const errorContainer = document.getElementById('error');
const pdfViewerContainer = document.getElementById('pages-container');
const loader = document.getElementById('loader');
const pdfFileUrl = "sample-pdf-with-images.pdf";
renderPdf(
url = pdfFileUrl,
onPdfLoaded = () => loader.classList.add('hidden-with-animation'),
onError = error => {
loader.style.display = 'none';
console.error(error);
errorContainer.style.display = 'block';
pdfViewerContainer.style.display = 'none';
errorContainer.innerText = error.message;
});
}, false);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment