Print PDF to iFrame from parent frame in Firefox

So, I have a main document that contains an iFrame, which contains a PDF file containing a barcode (created by iTextSharp and size for a Dymo Label printer).

HTML looks something like this:

<html>
    <body>
       <div class="content">
           <iframe src="/pdfs/label.pdf" NAME="loyaltyBadge" ID="loyaltyBadge"></iframe>
               <br/>
           <button id="printPdf">Print</button>
       </div>
    </body>
</html>

Using jQuery or standard JS, how can I get a button to start a print dialog in a PDF frame?

It:

$('#printPdf').click(function () {
    document.loyaltyBadge.print();
});

It seems to work in Chrome, but not in FF, where I get an error document.loyaltyBadge is undefined

I tried Google, but most of the results come from people suggesting where the document in the iFrame is HTML, so we can put print control in the iFrame, which of course I can’t do in this case.

iFrame is small, so the built-in print control from the built-in Adobe Reader is not needed.

+3
source share

All Articles