title: How do you prevent an entire PDF file to be downloaded in PDF.js?
body: <p>If you go to <a href="https://jsfiddle.net/pdfjs/wagvs9Lf/" rel="nofollow noreferrer">this</a> page you will see an example of how <a href="https://github.com/mozilla/pdf.js/" rel="nofollow noreferrer">PDF.js</a> works.  When clicking on &quot;Run&quot; button, you will see it successfully downloads the entire 14 pages of the PDF file and initially displays the first page.  When you click on the &quot;Next&quot; button it will show you the next page of the PDF file (if one exists).</p>
  <p>My question: How do you prevent PDF.js from downloading all 14 pages and only download the first 3 pages? Note that you can show only the first 3 pages by making the following change in JS Fiddle below:</p>
  <p>Change:</p>
  <pre><code>function onNextPage() {
    if (pageNum &gt;= pdfDoc.numPages) {
      return;
    }
    pageNum++;
    queueRenderPage(pageNum);
  }
  </code></pre>
  <p>to</p>
  <pre><code>/**
   * Displays next page.
   */
  function onNextPage() {
    if (pageNum &gt;= 3) { // &lt;--- don't show beyond 3rd page
      return;
    }
    pageNum++;
    queueRenderPage(pageNum);
  }
  </code></pre>
  <p>But the problem with this is if you go to the javascript console and enter:</p>
  <pre><code>renderPage(14)
  </code></pre>
  <p>PDF.js will show you the 14th page.  This means the entire PDF file has been downloaded, however I only want the first 3 pages to be downloaded.  We are working with PDF files that can be 500 or 1000 pages, so limiting the amount to download is key here.</p>
  <p>Would appreciate all / any advise on how this can be done in PDF.js.</p>