title: pdf file is corrupted when a file encoded in base64 is downloaded
body: <p>I try to download a pdf file that has been previously encoded using base 64.</p>
  
  <p>I try to download it from an anchor tag, as follows</p>
  
  <pre><code>&lt;a href="data:application/pdf;base64,JVBERi0xLjUKJbXtrvsKMyAwIG9..." download="file.pdf"&gt;Download&lt;/a&gt;;
  </code></pre>
  
  <p>The file is downloaded but when I try to open it I get a message that the file has damage or is corrupted.</p>
  
  <p>Interestingly, if I change href to an encode image data, the file is downloaded and opened as expected.</p>
  
  <p>I found this example <a href="http://jsfiddle.net/filixix/0816jdfq/" rel="nofollow noreferrer">http://jsfiddle.net/filixix/0816jdfq/</a> and I see that is changed from <code>data:application/pdf;base64,</code> to <code>data:application/octet-stream;base64</code>, I tried but I am getting the same result.</p>
  
  <p><strong>Update</strong></p>
  
  <p>I am encode the pdf file as follows</p>
  
  <pre><code>const element = document.querySelector('#file'); // input type file
  
  element.addEventListener('change', handleChange);
  
  function handleChange() {
      const file = this.files[0];
      const fileReader = new FileReader();
  
      fileReader.onload = function() {
          const data = this.result;
  
          //  store data in database in a text type field
      };
  
      fileReader.readAsDataURL(file);
  }
  </code></pre>
  
  <p>hen, in the view where I want to download the file, I realize the logic that I commented</p>