JavaScript - auto-print iframe or pdf

Asked By Don Crossman on 12-Nov-06 04:05 PM

I've been searching for a week, at least, for this. I need to auto-print (and close) an IE window containing a pdf document.

I thought I could do it by putting the pdf into an <iframe> and then doing a "window.print(); window.close()" but no joy. I also tried Robbe Morris' method for "document.iframe.focus(); document.iframe.print()" but that doesn't work for a pdf.

I'm using IE 7 and Acrobat Reader 7. Any thoughts would be really appreciated. Thanx.

Here's the issue:

Peter Bromberg replied to Don Crossman on 12-Nov-06 05:35 PM

the Javascript window.print method will bring up a printer dialog on the client browser, but it is only capable of printing the html contents of the window. When you display a PDF document in a window (frame, IFrame, doesn't matter) you are invoking the Acrobat Reader plug-in to load and display this PDF document. At that point, you could only print the PDF by using the Acrobat Reader's Print button, because the PDF is now hosted in the Reader ActiveX control. It's possible you might be able to use scripting to get the Reader to do its "print" function, but I don't remember ever seeing it.

Hope that helps.

Thanks

Don Crossman replied to Peter Bromberg on 12-Nov-06 06:57 PM
That's what I kind of figured. Thanks for the explanation, though. A lot of people have asked this same thing on a lot of forums -- you'd think Adobe could take a hint...

auto-print iframe or pdf

js dev replied to Don Crossman on 29-Jan-08 10:30 AM
were you able to do this? same question. thanks