Welcome Guest Search | Active Topics | Sign In | Register

How to print editor contents Options
eo_support
Posted: Wednesday, July 8, 2009 12:13:19 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
The HTML Editor control does not have print feature built-in but it is very easy to implement it with JavaScript. The following code opens a new window (the printer friendly version), write the Editor contents into the window and then call the window's print method to invoke the print dialog:

Code: JavaScript
function print_editor_content()
{
    //Get the editor object
    var editor = eo_GetObject("Editor1");

    //Open the new "printer friendly" window
    var wnd = window.open("", "whatever");

    //Write some basic HTML code into the page
    //Most likely you will need to change this part,
    //such as including your custom styles, etc
    wnd.document.open();
    wnd.document.write("<html>");
    wnd.document.write("<head>");
    wnd.document.write("<title>Print Editor Content</title>");
    wnd.document.write("</head>");
    wnd.document.write("<body>");

    //Write the editor content
    wnd.document.write(editor.getHtml());

    //Close the document
    wnd.document.write("</body>");
    wnd.document.write("</html>");
    wnd.document.close();

    //Invoke the print dialog
    wnd.print();
}


The Editor does not have print built-in because people rarely want to print just the editor contents alone. So most of the time user will need to customize the header and other page contents that appears along with the editor content.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.