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

RadEditor custom print external images

3 Answers 70 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Roland Klug
Top achievements
Rank 1
Roland Klug asked on 03 Sep 2014, 04:33 PM
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

3 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 04 Sep 2014, 12:37 PM
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.

 
0
Roland Klug
Top achievements
Rank 1
answered on 08 Sep 2014, 10:22 AM
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
0
Ianko
Telerik team
answered on 10 Sep 2014, 07:09 AM
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.

 
Tags
Editor
Asked by
Roland Klug
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Roland Klug
Top achievements
Rank 1
Share this question
or