title: How to pass uploaded pdf file to the variable. (PDF.JS)
body: <p>Reference : <a href="http://git.macropus.org/2011/11/pdftotext/example/" rel="nofollow">http://git.macropus.org/2011/11/pdftotext/example/</a></p>
  
  <p>In this project developer has taken a pdf as input and pass it to variable "input". <strong>I want to create an upload menu/dropzone</strong> so that anyone can  upload their pdf and it automatically get passed to the variable "input" and text can be extracted. <strong>I am able to upload the file</strong> <strong>but don't know how to pass that pdf to the variable "input".</strong></p>
  
  <pre><code>&lt;body&gt;
      &lt;form id="upload" method="post" action="upload.php" enctype="multipart/form-data"&gt;
            &lt;div id="drop"&gt;
              Drop Here
                  &lt;a&gt;Browse&lt;/a&gt;
              &lt;input id="inputx" src="./"type="file" name="upl" multiple /&gt;
            &lt;/div&gt;
  
            &lt;ul&gt;
              &lt;!-- The file uploads will be shown here --&gt;
            &lt;/ul&gt;
  
          &lt;/form&gt;
  </code></pre>
  
  <p>Now using this form a pdf will be uploaded now we have to pass it the variable "input ".</p>
  
  <pre><code>          &lt;script&gt;     
            var input = document.getElementById("input");
            var processor = document.getElementById("processor");
            var output = document.getElementById("output");
  
            window.addEventListener("message", function(event){
              if (event.source != processor.contentWindow) return;
  
              switch (event.data){
                case "ready":
                  var xhr = new XMLHttpRequest;
                  xhr.open('GET', input.getAttribute("src"), true);
                  xhr.responseType = "arraybuffer";
  
                  xhr.onload = function(event) {
                    processor.contentWindow.postMessage(this.response, "*");
                  };
  
                  xhr.send();
  
                break;
  
                default:
                   output.innerHTML = event.data.replace(/\s+/g, " ");
                  break;
              }
            }, true);
            &lt;/script&gt;
      &lt;/body&gt;
  </code></pre>