Print a picture from a picturebox

2 posts, 0 answers
  1. Roh
    Roh avatar
    1 posts
    Member since:
    May 2012

    Posted 26 Jan 2019 Link to this post


    I have a problem.

    How can print a picture from a picturebox?

    How can put correct object in Associateobjet to print it?

  2. Hristo
    Hristo avatar
    1522 posts

    Posted 28 Jan 2019 Link to this post

    Hi Roh,

    The RadPrintDocument can only be used with RadControls implementing the IPrintable interface. This is also the type of the AssociatedObject property. If you want to use it with a standard picture box, you will need to inherit it and implement the interface similarly as demonstrated here:

    Please also check my code snippet below: 
    public class PrintablePictureBox : PictureBox, IPrintable
        public int BeginPrint(RadPrintDocument sender, PrintEventArgs args)
            return 1;
        public bool EndPrint(RadPrintDocument sender, PrintEventArgs args)
            return true;
        public Form GetSettingsDialog(RadPrintDocument document)
            return new PrintSettingsDialog(document);
        public bool PrintPage(int pageNumber, RadPrintDocument sender, PrintPageEventArgs args)
            Bitmap bmp = new Bitmap(this.Width, this.Height);
            this.DrawToBitmap(bmp, new Rectangle(Point.Empty, this.Size));
            args.Graphics.DrawImage(bmp, Point.Empty);
            return false;
        public void Print()
            RadPrintDocument doc = this.CreatePrintDocument();
        public void PrintPreview()
            RadPrintDocument doc = this.CreatePrintDocument();
            RadPrintPreviewDialog dialog = new RadPrintPreviewDialog(doc);
        private RadPrintDocument CreatePrintDocument()
            RadPrintDocument doc = new RadPrintDocument();
            doc.AssociatedObject = this;
            return doc;

    I hope this will help.

    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top