8

I'm opening an editable form PDF (opened via the acrobat plugin) in an iframe:

<iframe name="iframe_content" id="iframe_content" src="mypdf.pdf"></iframe>

There is a button that calls the following print function:

function printContent(){
    window.frames["iframe_content"].focus();
    window.frames["iframe_content"].print();
}

It works in Chrome, Safari, IE8, but not in IE9.
In IE9 i receive the following error in reference to the printContent() function:

Invalid calling object 

I think this may be the trick to getting it to work, but I'm not sure how to make window.frames fit within this structure: http://msdn.microsoft.com/en-us/library/ie/gg622930%28v=vs.85%29.aspx

UPDATE: Decided that for this single page the simplest solution was forcing the browser into IE8 compatibility mode using the <meta> tag and X-UA-Compatible

kylex
  • 14,178
  • 33
  • 114
  • 175

1 Answers1

-3

You must put your print function inside the Iframe's page and call it from the parent page.

in Iframe:

function printMe() {
    window.print()
}

in parent (assuming this is the first iframe on your page):

frames[0].printMe()
Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
  • 2
    The issue is really with "Invalid calling object" on window.frames["iframe_content"]. I'm looking for a workaround for that issue. How do I make window.frames a valid calling object? – kylex Jun 21 '12 at 18:08
  • On IE I imagine that the PDF takes over the iframe at an application-level though active-x - so there is no web page there anymore. Just the PDF viewer. – Diodeus - James MacFarlane Jun 21 '12 at 18:34
  • Ended up just forcing the browser into IE8 compatibility mode. Not the best solution, but it works :p – kylex Jun 21 '12 at 19:27