New to Telerik UI for WinFormsStart a free 30-day trial

How to print image from RadImageEditor

Updated over 6 months ago

Environment

Product VersionProductAuthor
2021.2.511RadImageEditor for WinFormsNadya Karaivanova

Description

RadImageEditor does not support printing out of the box. However, you can easily achieve this by adding an additional button and implement the print functionality in RadImageEditor using PrintDocument.

This article demonstrates how to achieve printing in RadImageEditor.

how-to-print-from-radimageeditor001

Solution

Let's first create the print button, add it to the CommandsElement and handle it's Click event:

C#
public RadForm1()
{
    InitializeComponent();
    RadButtonElement printButton = new RadButtonElement();
    printButton.Image = Resources.printer_icon;
    printButton.Click += this.PrintButton_Click;

    var buttonContainer = radImageEditor1.ImageEditorElement.CommandsElement.TopCommandsStackElement;
    buttonContainer.Children.RemoveAt(3);
    buttonContainer.Children.RemoveAt(2);
    buttonContainer.Children.Add(printButton);
}

Then, in the print button's Click event you can print the PrintDocument that contains the current image from RadImageEditor:

C#
private void PrintButton_Click(object sender, EventArgs e)
{
    PrintDocument printDocument = new PrintDocument();
    printDocument.PrintPage += PrintPage;
    printDocument.Print();
}
private void PrintPage(object o, PrintPageEventArgs e)
{
    System.Drawing.Image img = radImageEditor1.CurrentBitmap;
    Point loc = new Point(100, 100);
    e.Graphics.DrawImage(img, loc);
}

In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support