Posted 16 August 2020, 11:00 am EST
I recently downloaded an unlicensed PDF Viewer through NPM (and even tried using the ZIP). Everything seems to be working, except it won't actually load the PDF.The PDF and javascript are currently in the same folder as my index.html, but every time I test the code in Chrome (and even tried Edge), an error that states "Missing PDF" pops up, and I'm not sure what to do to get it to actually load my PDF.
I've followed the documentation pretty thoroughly, but to no avail, using the following resources: one, two, three
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<title>GrapeCity Documents PDF Viewer</title>
<script type="text/javascript" src="gcpdfviewer.js"></script>
<script type="text/javascript" src="gcpdfviewer.worker.js"></script>
<script>
function loadPdfViewer(selector) {
var viewer = new GcPdfViewer(selector,
{
/* Specify options here */
renderInteractiveForms: true
});
// Skip the 'report list' panel:
// viewer.addReportListPanel();
viewer.addDefaultPanels();
// Optionally, open a PDF (will only work if this runs from a server):
viewer.open('hello.pdf');
// Change default toolbar:
var toolbar = viewer.toolbar;
toolbar.updateLayout({
default: ['$navigation', '$split', 'text-selection', 'pan', '$zoom', '$fullscreen',
'save', 'print', 'rotate', 'view-mode', 'doc-title']
});
}
</script>
</head>
<body onload="loadPdfViewer('#root')">
<div id="root"></div>
</body>
</html>
I currently have the "hello.pdf" and the gcpdfviewer javascripts in the same folder as the above index.html but every time I test the code in the browser, the PDF viewer loads, but the PDF doesn't, giving me an error that states "missing PDF."
This is really bothering me because the PDF is exactly where it's supposed to be, I think.
I'm currently not using a license key, but the documentation makes it seems like I don't need one. Maybe that's the issue.
Any ideas?