This is a migrated thread and some comments may be shown as answers.

Printing with styles

2 Answers 65 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Karl Wigart
Top achievements
Rank 1
Karl Wigart asked on 12 May 2009, 01:47 PM
I have tried to get your example (http://www.telerik.com/help/aspnet-ajax/printingcontentwithstyles.html) to work in Firefox but it is not working.

When I click the custom print button, the iframe is created and then nothing happens and the status of the browser is reporting "stopped" rather than done.

It all works fine in IE 7.

I'm using Telerik version 2009.1.402.35 and Firefox 3.0.10

I have tried it on a different machine with the same version of Firefox.

Any suggestions would be helpful.

Karl

2 Answers, 1 is accepted

Sort by
0
Rumen
Telerik team
answered on 15 May 2009, 10:02 AM
Hi Karl,

I was able to print the content in FF3.0.10 by closing the print document after the print() method execution, e.g.

 <telerik:RadEditor runat="server" ID="RadEditor1"
   <Tools> 
       <telerik:EditorToolGroup > 
           <telerik:EditorTool Name="CustomPrint" /> 
       </telerik:EditorToolGroup> 
   </Tools>   
   <Content> 
    <span class="Test">sample test content</span> 
   </Content> 
</telerik:RadEditor>  
 <script type="text/javascript"
Telerik.Web.UI.Editor.CommandList["CustomPrint"] = function(commandName, editor, args) 
   var printIframe = document.createElement("IFRAME"); 
   document.body.appendChild(printIframe); 
   var printDocument = printIframe.contentWindow.document
   printDocument.designMode = "on"
   printDocument.open(); 
   var currentLocation = document.location.href; 
   currentLocation = currentLocation.substring(0, currentLocation.lastIndexOf("/") + 1); 
   printDocument.write( "<html><head></head><body>" + editor.get_html(true) + "</body></html>"); 
    
   try 
   { 
       if ($telerik.isIE) 
       { 
         var oLink = printDocument.createElement("link"); 
         oLink.setAttribute( "href", currentLocation + "PrintWithStyles.css", 0); 
         oLink.setAttribute( "type""text/css"); 
         oLink.setAttribute( "rel""stylesheet", 0); 
         printDocument.getElementsByTagName( "head")[0].appendChild(oLink); 
         printDocument.execCommand("Print"); 
       } 
       else if ($telerik.isFirefox) 
       { 
         printDocument.body.innerHTML = "<link rel='stylesheet' type='text/css' href='" + currentLocation + "PrintWithStyles.css'></link>" + printDocument.body.innerHTML
         printIframe.contentWindow.print(); 
       } 
       //Telerik changed: close here the print document 
       printDocument.close(); 
   } 
   catch(ex) 
   { 
   } 
   document.body.removeChild(printIframe); 
}; 
</script>  

For your convenience I have attached my test page.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Karl Wigart
Top achievements
Rank 1
answered on 15 May 2009, 10:29 AM
Thanks Rumen,

That works.

Karl
Tags
Editor
Asked by
Karl Wigart
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Karl Wigart
Top achievements
Rank 1
Share this question
or