RadEditor custom print external images

4 posts, 0 answers
  1. Roland Klug
    Roland Klug avatar
    26 posts
    Member since:
    Dec 2002

    Posted 03 Sep 2014 Link to this post

    Hi,

    I use your code from "http://www.telerik.com/help/aspnet-ajax/editor-printing-content-with-styles.html" to print the RadEditor html content and some additional custom information. In particular, I add some email information (sender, recipient, etc.) as the editor is used in an email web client.

    A problem arises in the case of external images referenced in the html content, e.g. "<img width="1600" height="900" id="Grafik_x0020_1" src="/an_image_url_comes_here">". These images are not printed. However, the default RadEditor print function does work fine in this case.

    How do I make the external images to be printed as well in the custom code?

    My code looks like this:

            Telerik.Web.UI.Editor.CommandList["CustomPrint"] = function (commandName, editor, args) {
                var printIframe = document.createElement("IFRAME");
                document.body.appendChild(printIframe);
                var printDocument = printIframe.contentWindow.document;
                printDocument.designMode = "on";
                printDocument.open();

                printDocument.write("<html><head></head><body>" + editor.get_html(true) + "</body></html>");
                printDocument.close();

                try {
                    if (document.all) {
                        printDocument.execCommand("Print");
                    }
                    else {
                        printIframe.contentWindow.print();
                    }
                }
                catch (ex) {
                    window.alert("error");
                }
                
                //document.body.removeChild(printIframe);
            };

    Many thanks!!!

    Roland
  2. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 04 Sep 2014 Link to this post

    Hello Roland,

    The provided approach just creates a new documents with the additional CSS or HTML content desired to be printed.

    I suggest you trying to get the generated HTML with the mentioned image/s and try building a simple HTML file to locally investigate if this is not a side effect from the HTML that is printed.

    This functionality entirely depends on the browser and the HTML inserted. The RadEditor control do not have the control over the printed content after dynamically modifying it.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Roland Klug
    Roland Klug avatar
    26 posts
    Member since:
    Dec 2002

    Posted 08 Sep 2014 in reply to Ianko Link to this post

    Hi lanko,

    thank you for your reply.

    Do you have any idea how we can otherwise achive our goal, which is to insert some additional lines above the actual editor content. We use the editor in a html web client to show the email content, and we'd like to add information about sender, recipients, attachments, etc. when the content is printed.

    Of course, the images in the email content should be printed as well.

    Thank you!
    Roland
  5. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 10 Sep 2014 Link to this post

    Hi Roland,

    I am unable to suggest another possible way to generate additional content for printing purposes.

    Generally, this is the browser supported functionality to print an HTML document from the browser. Only the generated iframe elements are possible to print isolated documents.

    Regards,
    Ianko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top