Printing when Div-mode

3 posts, 0 answers
  1. Andreas
    Andreas avatar
    137 posts
    Member since:
    May 2008

    Posted 30 Mar Link to this post

    Hi,

    When using the print toolbar button, the whole page is printed instead of the actual Editor content!

    We are using Div-mode for several reasons...

    This is also the case in your demo:
    http://demos.telerik.com/aspnet-ajax/editor/examples/contentareamodediv/defaultcs.aspx

    Regard
    Andreas
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 04 Apr Link to this post

    Hi Andreas,

    When using div content area there is no separate document to be printed. 

    You can, however, customize your own custom Print tool that extracts the content in a dialog and prints it. The solution is demonstrated here in this draft article that will be live shortly—https://github.com/telerik/ajax-docs/blob/master/controls/editor/how-to/print-content-div-contentareamode.md.

    Regards,
    Ianko
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andreas
    Andreas avatar
    137 posts
    Member since:
    May 2008

    Posted 04 Apr in reply to Ianko Link to this post

    Ok!

    I did it with a hidden iframe instead, to get rid of the ugly window...

    Telerik.Web.UI.Editor.CommandList['Print'] = function (commandName, editor, args)
            {
                var prtContent = editor.get_contentArea();
                var iFrame = document.createElement('iframe');
                iFrame.style.display = 'none';
     
                document.body.appendChild(iFrame);
     
                iFrame.contentDocument.write(prtContent.innerHTML);
                iFrame.contentDocument.close();
                if ($telerik.isIE)
                    iFrame.contentDocument.execCommand('print');
                else
                    iFrame.contentWindow.print();
     
                iFrame.parentNode.removeChild(iFrame);
            };

    I think this should be default in the Editor control so that we don't have to do so many hacks!

    Regard
    Andreas
Back to Top