jQWidgets Forums

jQuery UI Widgets Forums Dialogs and Notifications Window Printing content of window

This topic contains 4 replies, has 2 voices, and was last updated by  sjkcwatson 9 years, 10 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • Printing content of window #71140

    sjkcwatson
    Participant

    Is there a way to print the content of a window? Or another approach that would work – frame, etc? Just need to print the html formmatted content. Thanks!

    Printing content of window #71141

    sjkcwatson
    Participant

    Or the content of one tab?

    Printing content of window #71164

    Nadezhda
    Participant

    Hello sjkcwatson,

    Unfortunately, exporting from jqxWindow is not available. You may try the following example as a workaround which exports window’s content in file: http://jsfiddle.net/9fjLah0p/.

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

    Printing content of window #71168

    Nadezhda
    Participant

    Hi sjkcwatson,

    Here is another example which shows how to get the Windows’s HTML, add it to a new browser window and trigger printing.

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <title></title>
        <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
        <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
        <script type="text/javascript" src="../../jqwidgets/jqxwindow.js"></script>
    </head>
    <body>
        <div id='content'>
            <script type="text/javascript">
                $(document).ready(function () {
                    $("#jqxwindow").jqxWindow({
                        height: 100,
                        width: 300,
                    });
                    $("#print").jqxButton();
                    $("#print").click(function () {
                        var content = $('#jqxwindow').jqxWindow('content');
                        var newWindow = window.open('', '', 'width=300, height=100'),
                            document = newWindow.document.open(),
                             pageContent =
                            '<!DOCTYPE html>\n' +
                            '<html>\n' +
                            '<head>\n' +
                            '<meta charset="utf-8" />\n' +
                            '<title>jQWidgets Window</title>\n' +
                            '</head>\n' +
                            '<body>\n' + content + '\n</body>\n</html>';
                        document.write(content);
                        document.close();
                        newWindow.print();
                    });
                });
            </script>
            <div id='jqxwindow'>
                <div>Header</div>
                <div>Content</div>
            </div>
            <div style='margin-left: 10px; float: left;'>
                <input type="button" value="Print" id='print' />
            </div>
        </div>
    </body>
    </html>

    Best Regards,
    Nadezhda

    jQWidgets team
    http://www.jqwidgets.com/

    Printing content of window #71178

    sjkcwatson
    Participant

    Thank you – I appreciate the help and will try it.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.