export314x251

Formats

It is possible to export the Calendar into several image formats:

  • BMP
  • GIF
  • JPEG
  • PNG
  • TIFF
  • other formats supported by Bitmap.Save()

Use Cases

  • Print the exported image easily.
  • Save the exported image to a file.
  • Non-web applications:
    • Show a read-only calendar in WebForm applications
    • Include it in PDF files generated on the server
    • Include it in generated e-mails

Modes

  • Special page: Place DayPilotCalendar (with the same configuration as on the dynamic page) on a special page and overwrite the Response stream in all cases.
  • PostBack: Use a button on an existing page and overwrite the Response stream in the button Click event handler (returns the image after clicking a button).
  • Desktop/server/console applications: Create the control dynamically and export the image from any other kind of application.

CSS

CSS styling is not supported during image export. You need to style the calendar using the inline properties that were used in the legacy CssOnly=false mode.

Signatures

public MemoryStream Export(ImageFormat format);
public MemoryStream Export(ImageFormat format, int scrollPosition);

Example

protected void ButtonExport_Click(object sender, EventArgs e)
{
  int hourHeight = DayPilotCalendar1.CellsPerHour*DayPilotCalendar1.CellHeight;

  Response.Clear();
  Response.ContentType = "image/png";
  MemoryStream img = DayPilotCalendar1.Export(ImageFormat.Png, 9 * hourHeight);
  img.WriteTo(Response.OutputStream);
  Response.End();
}

Tutorial

See Also