# Creating an ImageEditor Print Command

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>Progress Telerik UI for ASP.NET MVC</td>
 </tr>
</table>

## Description

How can I print the edited image from the Telerik UI for ASP.NET MVC ImageEditor?

## Solution

Create a [custom command](https://docs.telerik.com/aspnet-core/html-helpers/editors/imageeditor/tools#adding-custom-commands-to-the-toolbar) and use it to print the image.

The below example demonstrates how you can create a Print command:

```
<script>
     var imageEditorNS = kendo.ui.imageeditor;

        imageEditorNS.commands.PrintImageEditorCommand = imageEditorNS.ImageEditorCommand.extend({
          exec: function () {
            var that = this,
                options = that.options,
                imageeditor = that.imageeditor,
                canvas = imageeditor.getCanvasElement(),
                ctx = imageeditor.getCurrent2dContext(),
                image = imageeditor.getCurrentImage();

            var win = window.open('about:blank', "_new");
            win.document.open();
            win.document.write([
              '<html>',
              '   <head>',
              '   </head>',
              '   <body onload="window.print()" onafterprint="window.close()">',
              '       <img src="' + image.src + '"/>',
              '   </body>',
              '</html>'
            ].join(''));
            win.document.close();
          }
        });
</script>

<div class="demo-section wide">
    @(Html.Kendo().ImageEditor()
        .Name("imageEditor")
        .Height(900)
        .SaveAs(s => s.FileName("image_edited.png"))
        .Toolbar(toolbar=>toolbar.Items(i=> {
            i.Add().Name("open");
            i.Add().Name("save");
            i.Add().Name("resize");
            i.Add().Name("crop");
            i.Add().Name("undo");
            i.Add().Name("redo");
            i.Add().Name("zoomIn");
            i.Add().Name("zoomOut");
            i.Add().Name("zoomDropdown");
            i.Add().Command("PrintImageEditorCommand").Type("button").Text("Print").Icon("print");
        }))
    )
</div>
```

Refer to this [REPL](https://netcorerepl.telerik.com/mmkzQEEi225iCf3606) for a runnable example.

## More ASP.NET MVC ImageEditor Resources

* [ASP.NET MVC ImageEditor Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/editors/imageeditor/overview)

* [ASP.NET MVC ImageEditor Demos](https://demos.telerik.com/aspnet-mvc/imageeditor)

* [ASP.NET MVC ImageEditor Product Page](https://www.telerik.com/aspnet-mvc/image-editor)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Telerik REPL: Creating an ImageEditor Print Command](https://netcorerepl.telerik.com/mmkzQEEi225iCf3606)
* [Client-Side API Reference of the ImageEditor for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/imageeditor)
* [Server-Side API Reference of the ImageEditor for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/imageeditor)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
