PDA

View Full Version : Printing a document in iframe



sashdce
1 Dec 2009, 5:15 PM
I have a document (PDF ) that opens up in iframe . The iframe is a template in a dataview included in a panel , in turn included in a window. The window opens up as a popup.

I want to print the document in the iframe. I added a button name "Print" in the tbar and added the handler for the click. I made the following 3 attempts for print.

'lookupframe' is the id of the iframe .

Attempt 1 : Empty page is printed ( no preview comes up in the print box) . The path of the document is correctly printed at the bottom of the page.

Attempt 2 : Empty page is printed ( no preview comes up in the print box) . The path of the document is correctly printed at the bottom of the page.

Attempt 3 : Get a "Access Denied" javascript error.


// Attempt 1
handler : function(){

window.frames['lookupframe'].focus();

window.print();
}

// Attempt 2
handler : function(){

window.frames['lookupframe'].focus();
document.execCommand('print');

}

// Attempt 3
handler : function(){

window.frames['lookupframe'].focus();

window.frames['lookupframe'].print();

}
[/CODE]

Please guide for a resolution. The browser is IE.

balybaloo
10 Dec 2009, 5:22 AM
I have the same problem !
Have you find a solution ?

Condor
10 Dec 2009, 5:34 AM
For an IFRAME with HTML in it you would use the third option (on IE you need to use contentWindow instead of frame[]), but this probably won't work when plugin (.pdf) is loaded.

sashdce
10 Dec 2009, 4:07 PM
The issue with me was that I have a websphere and apache ( on which i store the documents). Now the code executes in WS where the file has to be fetched from apache, which is fine. However, when i try and print , it need to get some security access across the server, which it fails. Hence, the solution was to create the folder and put the PDF file on websphere itself. Then u can use the above code.
Problem resolved for me.