Solved

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

Posted on 2011-09-13
1
318 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 83

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following article is comprised of the pearls we have garnered deploying virtualization solutions since Virtual Server 2005 and subsequent 2008 RTM+ Hyper-V in standalone and clustered environments.
Determining the an SCCM package name from the Package ID
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the adminiā€¦

739 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