Print window content in EXT 4.2.1

Page 1 of 2 12 LastLast
  1. #1

    Print window content in EXT 4.2.1

    Hello guys!

    I'm trying to print the content of a ext window. In the window i have an iframe with a pdf.
    I'm able to print the content on google chrome, but on IE the best i can get is the content of the parent window.
    I send you my function.

    //report request
    var request = frontController + 'report/test?' 
    + "p_cod_opcao=873&p_cod_rep=873&p_cod_mod=INT&p_dta _inicial=12/12/2013&p_dta_final=12/12/2013&p_cod_dest=&p_cod_esp=&p_tipo_serv=F";
    //destroy window
    //Ext.WindowManager.each(function(cmp) { if (cmp.itemId === 'reportWindow') cmp.destroy(); });
    //ext window with hidden iframe
    var win = new Ext.Window ({
    itemId: 'reportWindow',
    width: 800, 
    height: 600, 
    title: 'Relatorio',
    html: '<iframe src="'+request+'" id="reportFrame" id="reportFrame" name="reportFrame" style="visibility:hidden;display:none" ></iframe>'
    //print works on CHROME
    Thank you for the attention hope you can help me!
    Last edited by Daniil; Dec 23, 2013 at 11:06 AM. Reason: Please use [CODE] tags
  2. #2
    Hi @GusMartins,

    Welcome to the Ext.NET forums!

    I discovered that the following works in IE8, but not in IE9. I don't know why. Maybe, Google might help. Anyway, the problem is not related to Ext.NET.

    <%@ Page Language="C#" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <iframe id="iframe1" src="resources/diffe/test.pdf"></iframe>
            <ext:Button runat="server" Text="Print" Handler="window.frames['iframe1'].print();" />
  3. #3
    I am using Internet Explorer 11. I was trying to add a listener to the window:

    listeners: {
                        afterrender: function(){
    but it is still no working.

    I searched a lot but i wasn't able to find a working solution. Does anyone know another way of doing what i need?

    Last edited by geoffrey.mcgill; Dec 23, 2013 at 2:56 PM. Reason: Please use [CODE] tags
  4. #4
    I tested my sample in IE 11. It appears to be working. Does it work for you?

    I guess the "afterrender" listener might be too early to call the print method. The iframe might be not loaded yet. I would try to call it inside a loader's Load listener.
  5. #5
    Hey Dani!

    It's working now in IE . But i have a timeout to wait the document to load. How can i do to call it on loader's Load listener?

    var win = new Ext.Window ({
                  itemId: 'reportWindow',
    //              layout     : 'absolute',
    //              x: -2000,
    //              y:-2000,
                  width: 800, 
                  height: 600, 
                  title: 'Relatorio',
                  html: '<embed id="reportframe" src="'+request+'" width="500" height="500" name="reportframe">',
                  listeners: {
                      aferrender: function(){
                            if (browserName == "Microsoft Internet Explorer") {
                                    var report = document.getElementById("reportframe");
                            else if (browserName == "Chrome") {
                            else if (browserName == "Firefox") {
    Last edited by Daniil; Dec 30, 2013 at 1:13 PM. Reason: Please use [CODE] tags
  6. #6
    Oh, you don't use a Loader, sorry.

    I would try the onload event of the embed tag.
  7. #7

    please help me print pdf too..

    look at this example.. but i dont know id my iframe after loader

     <ext:Window ID="wndShowDoc" runat="server" Title="" Icon="UserHome" BodyPadding="0"  AutoScroll="true"  TagString="iframe"
               Width="900" Height="600"  Modal="true" Resizable="true" Closable="true" Hidden="true" Layout="Fit" CloseAction="Hide">
                    <ext:Panel runat="server" ID="PanelView">
                            <ext:Button ID="btPrints" runat="server" Text="Печать" Icon="Printer">
                                   <%--  <Click Handler="this.up('panel').getBody().print();" />--%> this good for print html file
                                   <Click Handler="this.up('iframe').contentWindow.print();" />
                           <ext:Button runat="server" Icon="Decline" Text="Закрыть" ID="btCloseView" >
                                            <Click Handler="this.up('window').hide();" />
                         <Loader ID="Loader1" 
                                        <ext:Parameter Name="ext" Value="pdf" Mode="Value" />
                                        <ext:Parameter Name="link" Value="c:\1\1.pdf" Mode="Value" />
                                        <ext:Parameter Name="pathToImage" Value=".\Images\" Mode="Value" />
  8. #8
    A Panel's getBody method returns an iframe's "window" global object. Hope this helps.
  9. #9
    Quote Originally Posted by Daniil View Post
    A Panel's getBody method returns an iframe's "window" global object. Hope this helps.
    Thanks.. i change my handler
      <Click Handler="App.PanelView.getBody().print();"  />

    in firebug - have error :Error: Permission denied to access property 'print'

    i load pdf file from local disk c:/1/1.pdf via loader.. but if click right click mouse on frame and in pop up menu browser - in this frame - print - printing this frame ok.
    and if i load html file without pdf - this print handler call print dialog very well.
    ps. ie10 - SCRIPT65535: Invalid calling object - on this print handler - html file from this directory - ok
    psps chrome pdf work - ok call dialog print, ff26-27,IE10,Ie11 - not work
    Last edited by asics167; Feb 05, 2014 at 6:42 AM. Reason: chrome work
  10. #10
    It appears to be a FireFox issue.

    Is it reproducible in other browsers?
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] Print window content
    By avante in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 17, 2014, 6:32 PM
  2. Print Engine for printing content
    By Bubu in forum Feature Requests
    Replies: 0
    Last Post: Sep 06, 2012, 5:01 AM
  3. [CLOSED] How I print ext:Window content?
    By supera in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 29, 2012, 4:00 PM
  4. Replies: 6
    Last Post: Feb 18, 2011, 2:12 PM
  5. Print content inside a panel
    By Nagaraj K Hebbar in forum 1.x Help
    Replies: 0
    Last Post: May 19, 2009, 2:14 AM

Tags for this Thread

Posting Permissions