Solved

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

Posted on 2011-09-13
1
314 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 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Troubleshooting common task sequence error codes
SEO can be a real minefield to navigate, but there are three simple ways to up your SEO game just be re-assessing your content output.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

776 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