Solved

Script does not print pdf in IE 6.0

Posted on 2006-06-15
3
206 Views
Last Modified: 2008-03-06
Hi,
 I have the following javascript which prints a PDF on click of a button. The script is supposed to open the print dialog box. It workd in IE 5.5 and FireFox but fails to work in IE .6.0. The following is the code:

function fn_printeport()
{
 var dummyVar;

   if(loadIframe("pdfWin", "../so/sodisplaypdf.do?rand="+Math.random()))
     {
       dummyVar = "dummyValue";        
     }
}

function loadIframe(iframeName, url) {
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;  
    return false;
  }
 
  else {
     return true;
  }
}

function fn_pdfprint()
{
var urlString = window.frames["pdfWin"].location.href;

if(urlString.indexOf("/so/sodisplaypdf.do") >= 0)
  {
  var delay="3000"; //delaying the print call (in ms)
  var string="fn_pauseforalert("+delay+");";
     //alert("javascript alert :Print will be delayed by "+delay+" ms");          
     setTimeout(string,delay);
  }
 

}


function fn_pauseforalert(delay)
{
 //alert("calling the print after delay of :"+ delay +" ms");

     var pdffileName = '<bean:write name="orderForm" property="salesOrderPDFFileName" />';    
     var pdffileName2 = '<bean:write name="orderForm" property="salesInvoicePDFFileName" />';    
 
 if(document.forms[0].printInvoice && pdffileName2!="")
  action="invoice";
 
 else if(document.forms[0].printOrder && pdffileName!="")
  action="delivery";
 
 
 
 if(action="")
 {
      alert("PDF not obtained.Please try again or later");
        return false;            
 }
 
 
 
 
 
 pdfWin.print();
 
}

IFRAMES are also being used:

<IFRAME   frameborder="0"  scrolling="auto" align = "top" hspace = 2 vspace = -300
width="100%" name="pdfWin" height="0" id="sup" onload="window.fn_pdfprint()">

Can anybody tell me why this happens?

Thanks,
Ajay.
0
Comment
Question by:ajaycv
3 Comments
 
LVL 30

Accepted Solution

by:
callrs earned 125 total points
ID: 16910267
http://www.lissaexplains.com/forum/showthread.php?t=43641     Printing an iframe - Lissa Explains it All: Web Design Forums
http://www.codelifter.com/main/javascript/printframe.shtml     CodeLifter.com - JavaScript Print Page From Different Frame

Based on the above tips, try:

window.frames['pdfWin'].focus();
window.frames['pdfWin'].print();

(or possibly this:
pdfWin.focus();
pdfWin.print();


0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

809 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