Mozilla

NAVIGATION
CATEGORIES
REFERRENCE
LINKS
  • How could I print my browser's content to the printer?

    12 answers - 576 bytes - related search similar search Add To My Delicious Add To My Stumble Upon Add To My Google Mark Add To My Facebook Add To My Digg Add To My Reddit

    created a xul window which embeded a browser window, added a printing
    button on this xul window .
    I want to print the browser's content to the printer, how should i do?
    I have used this JS code to start, but it doesn't work.
    funtion print()
    {
    PrintUtils.print(); // how could it work properly , like
    firefox?
    }
    //
    show my xul window like this,
    firefox.exe -chrome file:///c:/test/print.xul
    thank you, very much
    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.1 | | 409 bytes | |

    wushli (AT) gmail (DOT) com wrote:
    created a xul window which embeded a browser window, added a printing
    button on this xul window .
    --
    I want to print the browser's content to the printer, how should i
    do?

    See if this helps:

    the first user note at the bottom.

    Igor Tandetnik

    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.2 | | 225 bytes | |

    Greate,
    thanks , That's just i wanted. but I would have to have a test with it
    in any way!
    best wishes to you!
    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.3 | | 1961 bytes | |

    I have written an example file like so below:

    /// xul file

    <?xml version="1.0"?>

    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

    <window id="print-preview-window" title="print preview"
    xmlns:html="http://www.w3.org/1999/xhtml"
    width="600px" height="600px"

    xmlns="">

    <script type="application/x-javascript" src="printTest.js"/>

    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src="chrome://global/content/"/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src="chrome://browser/content/"/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src="chrome://global/content/viewZ"/>
    <script type="application/x-javascript"
    src=""/>

    <script type="application/x-javascript"
    src=""/>

    <iframe id="content-body" src="http://www.mozilla.org" flex="1"/>

    <toolbox>
    <toolbar id="P-toolbar">
    <toolbarbutton label="preview"/>
    <toolbarbutton label="print" oncommand="printHtml()"/>
    <textbox id="field"/>
    </toolbar>
    </toolbox>

    </window>

    // javascript file

    function printHtml()
    {

    var frame = document.getElementById("content-body");
    var req =
    frame.QueryInterface();
    var wbprint =
    req.getInterface();
    var settings = PrintUtils.getPrintSettings(); // from

    wbprint.print(settings, null);

    }

    // the problem is the example doesn't work properly.
    how could i do?

    thanks in advance

    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.4 | | 201 bytes | |

    wushli (AT) gmail (DOT) com wrote:
    <iframe id="content-body" src="http://www.mozilla.org" flex="1"/>
    Try type="content" or if that doesn't work then try type="content-primary".
  • No.5 | | 802 bytes | |

    It still doesn't work!

    the problem is the Components(for example:
    )never be initialized.

    the Components is null ;

    problem info:

    error: uncaught exception: [Exception "Component returned
    failure code: 0x80004002 (NS_NINTERFACE) [nsISupports.QueryInterface]"
    nsresult: "0x80004002 (NS_NINTERFACE)" location: "JS frame ::
    :: printHtml :: line 7" data:
    no]

    //
    function printHtml()
    {

    var frame = document.getElementById("content-body");
    var req =
    frame.QueryInterface();
    // line 7
    var wbprint =
    req.getInterface();
    var settings = PrintUtils.getPrintSettings(); // from

    wbprint.print(settings, null);

    }

    //

    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.6 | | 819 bytes | |

    wushli (AT) gmail (DOT) com wrote:

    >problem info:
    >
    >error: uncaught exception: [Exception "Component returned failure code: 0x80004002 (NS_NINTERFACE) [nsISupports.QueryInterface]" nsresult: "0x80004002 (NS_NINTERFACE)" location: "JS frame :: :: printHtml :: line 7" data: no]
    >
    >
    >//
    >function printHtml()
    >{
    >
    >var frame = document.getElementById("content-body");
    >var req =
    >frame.QueryInterface();
    >// line 7
    >var wbprint =
    >req.getInterface();


    frame has to be the actual frame, not the frame element try
    window.frames["content-body"] or
    document.getElementById("content-body").contentWindow or if you use
    <iframe type="content-primary"then you can use content as your frame.
  • No.7 | | 634 bytes | |

    Igor Tandetnik wrote:

    >created a xul window which embeded a browser window, added a printing
    >button on this xul window .
    >I want to print the browser's content to the printer, how should i
    >do?

    See if this helps:

    the first user note at the bottom.
    It works fine for me, but I trying to do the same for printPreview, and it works very strange. The preview appears
    inside the frame, replacing the content, but I want see a new window instead of it. What can be wrong?

    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.8 | | 808 bytes | |

    Anatolij Kupriyanov wrote:
    Igor Tandetnik wrote:
    >
    >created a xul window which embeded a browser window, added a printing
    >button on this xul window .
    >I want to print the browser's content to the printer, how should i
    >do?

    See if this helps:

    the first user note at the bottom.
    It works fine for me, but I trying to do the same for printPreview, and it works very strange. The preview appears
    inside the frame, replacing the content, but I want see a new window instead of it. What can be wrong?

    I have written an example which doesn't work. would you like to
    written a simlpy example for me, just show me how to use it.

    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.9 | | 197 bytes | |

    dear friend:]
    quit appreciating to you!
    I have resolved the prolblem
    thanks a lot.
    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.10 | | 196 bytes | |

    dear friend:
    quit appreciating to you!
    I have resolved the prolblem
    thanks a lot.
    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.11 | | 2245 bytes | |

    dear friend:

    quit appreciating to you!

    I have resolved the prolblem in the firefox's url bar. it works well.

    but when I open a window

    var win = window.open("", //
    printTest.xul is below
    "testDialog"
    ,"chrome"
    ,"width=500,height=500");

    it wouldn't work . I want it work in a seperator window , not the
    browser window. could you help me ?

    // printTest.xul source file

    <?xml version="1.0"?>

    <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>

    <window id="print-preview-window" title="print preview"
    xmlns:html="http://www.w3.org/1999/xhtml"
    width="600px" height="600px"

    xmlns="">

    <script type="application/x-javascript" src="printTest.js"/>

    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src="chrome://global/content/"/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src="chrome://browser/content/"/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src=""/>
    <script type="application/x-javascript"
    src="chrome://global/content/viewZ"/>
    <script type="application/x-javascript"
    src=""/>

    <script type="application/x-javascript"
    src=""/>

    <iframe id="content-body" src="http://www.mozilla.org" flex="1"/>

    <toolbox>
    <toolbar id="P-toolbar">
    <toolbarbutton label="preview"/>
    <toolbarbutton label="print" oncommand="printHtml()"/>
    <textbox id="field"/>
    </toolbar>
    </toolbox>

    </window>

    // javascript file

    function printHtml()
    {

    var frame = document.getElementById("content-body");
    var req =
    frame.QueryInterface();
    var wbprint =
    req.getInterface();
    var settings = PrintUtils.getPrintSettings(); // from

    wbprint.print(settings, null);

    }

    thanks a lot.

    dev-tech-xul mailing list
    dev-tech-xul (AT) lists (DOT) mozilla.org
  • No.12 | | 187 bytes | |

    wushli (AT) gmail (DOT) com wrote:

    ><iframe id="content-body" src="http://www.mozilla.org" flex="1"/>

    You might still need type="content"?

Re: How could I print my browser's content to the printer?


max 4000 letters.
Your nickname that display:
In order to stop the spam: 3 + 2 =
QUESTION ON "Mozilla"

EMSDN.COM