"Missing PDF" when testing app in browser

Posted by: blake on 16 August 2020, 11:00 am EST

  • 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">
    <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>
    function loadPdfViewer(selector) {
    var viewer = new GcPdfViewer(selector,
    /* Specify options here */
    renderInteractiveForms: true
    // Skip the 'report list' panel:
    // viewer.addReportListPanel();
    // Optionally, open a PDF (will only work if this runs from a server):
    // Change default toolbar:
    var toolbar = viewer.toolbar;
    default: ['$navigation', '$split', 'text-selection', 'pan', '$zoom', '$fullscreen',
    'save', 'print', 'rotate', 'view-mode', 'doc-title']
    <body onload="loadPdfViewer('#root')">
    <div id="root"></div>

    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?
  • Marked as Answer

    Replied 16 August 2020, 5:58 pm EST

    Hi William,

    Firstly, the issue is not because of the non-license version.
    The issue occurs because you are trying to execute the sample locally using the file system. To overcome this issue, you should host the application on a local server and the Pdf will be loaded in the PdfViewer.
    While loading a Pdf in the PdfViewer, there is XMLHttpRequest which checks the origin. This is null in the case of the file system. Hence, throws the error on accessing the file.
    Here is the documentation link for configuring the PdfViewer:

    Manish Gupta
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels