title: Print embedded PDF from browser with Javascript, HTML5, AngularJS
body: <p>I'm loading a Base64 encoded PDF as a String into my JavaScript from my server.  My client application is using AngularJS, HTML5.  </p>
  
  <p>My HTML looks like this: </p>
  
  <pre><code>&lt;div id="printablePdfContainer"&gt;
    &lt;iframe id="printablePdf" width="100%" height="100%"&gt;&lt;/iframe&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My JavaScript looks like this:</p>
  
  <pre><code>var pdfName = 'data:application/pdf;base64,' + data[0].PrintImage;
  var embeddedPdf = document.getElementById('printablePdf');
  embeddedPdf.setAttribute('src', pdfName);
  $scope.printDocument(embeddedPdf);
  </code></pre>
  
  <p>My <code>printDocument</code> function looks like this: </p>
  
  <pre><code>$scope.printDocument = function() {
        var test = document.getElementById('printablePdf');
        if (typeof document.getElementById('printablePdf').print === 'undefined') {
  
          setTimeout(function(){$scope.printDocument();}, 1000);
  
        } else {
  
          var x = document.getElementById('printablePdf');
          x.print();
        }
      };
  </code></pre>
  
  <p>The <code>printDocument</code> function has been taken from a pre-existing question in stack overflow (<a href="https://stackoverflow.com/questions/975652/silent-print-a-embedded-pdf">Silent print an embedded PDF</a>) which gives this as an answer to print an embedded PDF.  However, this doesn't seem to work anymore.  I'm always getting 'undefined' for the </p>
  
  <pre><code>typeof document.getElementById('printablePdf').print === 'undefined'
  </code></pre>
  
  <p>check.  Seems like <code>.print</code> doesn't exist or something.</p>
  
  <p>So, my question is this: How can I print an embedded PDF in HTML5, using JavaScript, and without opening a popup window?</p>