title: Print PDF in Firefox with Javascript
body: <p>I'm building an application running in Firefox on a terminal in a warehouse. This application needs to print PDFs.</p>
  
  <p>I found a lot of questions and answers about printing PDF from Javascript, but I can't get it to work.</p>
  
  <p>This is my current code.</p>
  
  <pre><code>$(document).ready(function() {
      $(document.body).append('&lt;IFRAME id="pdfLabel" ... &gt;');
      $('iframe#pdfLabel').attr('src', 'testlabel.pdf');
  
      $('iframe#pdfLabel').load(function() {
          document.getElementById('pdfLabel').focus();
          document.getElementById('pdfLabel').contentWindow.print();
      });
  });
  </code></pre>
  
  <p>With a regular html page in the iFrame, this code works flawlessly. With PDF, the pdf is displayed in the iFrame, but not printed. I tried printing with the Firefox built in PDF renderer and with embedded Adobe acrobat reader. I also tried</p>
  
  <pre><code>document.getElementById('pdfLabel').print();
  </code></pre>
  
  <p>But that throws 
  <code>TypeError: window.frames.pdfLabel.print is not a function</code></p>