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

Printing when Div-mode

2 Answers 108 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 30 Mar 2016, 01:20 PM

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 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 04 Apr 2016, 06:50 AM
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.
0
Andreas
Top achievements
Rank 1
answered on 04 Apr 2016, 12:01 PM

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
Tags
Editor
Asked by
Andreas
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Andreas
Top achievements
Rank 1
Share this question
or