The calendar (Calendar, Month, and Scheduler) can be easily exported as an image (PNG, BMP, JPG, and other image formats):
protected void ButtonExport_Click(object sender, EventArgs e) { DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.EventTextLeftIndent = 30; DayPilotMonth1.EventTextAlignment = TextAlignment.Left; Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("Content-Disposition", "attachment;filename=print.png"); DayPilotMonth1.Export(ImageFormat.Png).WriteTo(Response.OutputStream); Response.End(); }
If you want to add a header to the exported image (e.g. with the date or filter details) you have to draw the exported bitmap to a new one and add the header:
protected void ButtonExportHeader_Click(object sender, EventArgs e) { DayPilotMonth1.DataSource = getData(DayPilotMonth1.VisibleStart, DayPilotMonth1.VisibleEnd, (string)DayPilotMonth1.ClientState["filter"]); DayPilotMonth1.DataBind(); DayPilotMonth1.EventTextLeftIndent = 30; DayPilotMonth1.EventTextAlignment = TextAlignment.Left; Response.Clear(); Response.ContentType = "image/png"; Response.AddHeader("content-disposition", "attachment;filename=print.png"); int width = 1000; int height = 1000; Bitmap bmp = new Bitmap(width, height); Graphics g = Graphics.FromImage(bmp); g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; Image cal = DayPilotMonth1.ExportBitmap(); g.DrawImage(cal, 0, 50); string title = String.Format("{0:MMMM yyyy}", DayPilotMonth1.StartDate); Font font = new Font("Tahoma", 16, GraphicsUnit.Point); Brush brush = new SolidBrush(Color.Black); g.DrawString(title, font, brush, 0, 0); // PNG requires random access to the output stream MemoryStream mem = new MemoryStream(); bmp.Save(mem, ImageFormat.Png); mem.WriteTo(Response.OutputStream); Response.End(); }