Solved

Print a PDF document via Jscript without opening the pdf document.

Posted on 2011-09-13
1
312 Views
Last Modified: 2012-05-12
I'm using I.e 7.0 and I'm trying to print a PDF document via JScript. I just want to hit the print button and the print-wiindow should show up. The below code works but only prints-out the contents of the webpage but not the PDF document. I'm I missing something?

   <iframe id="iFramePdf" runat="server" src="tt877A6.pdf" style="display:none;"></iframe>
   <input type="button" value="Print" onclick="javascript:printTrigger('iFramePdf');" />

      function printTrigger(elementId) {
            var getMyFrame = document.getElementById(elementId);
           // alert(elementId);
           // iFramePdf.focus();
            //window.print();
            iFramePdf.focus();
            iFramePdf.print();
            //iFramePdf.contentDocument.print();
        }
   
0
Comment
Question by:7of9121098
1 Comment
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 125 total points
ID: 36531409
PDF's do not print directly on most printers.  Some program other than IE (like Adobe Reader) has to open the file to interpret the contents of the PDF document and send it to the printer.  Besides, all you can do in javascript is print the web page, you can't access a local file.  When you invoke the printer in javascript, you are calling the Print command on the web browser File menu.  That only prints web pages too.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Batch File to Telnet 10 3,153
Checkbox 4 355
Javascript animating div resize 3 117
Jscript & php in select drop downs 6 101
HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now