It is possible to export the Scheduler to PDF by embedding the exported image in a new PDF document.
Tutorial
Example
Example source code that uses PDFSharp library.
C#
private void ExportToPdf() { // create a new PDF document PdfDocument doc = new PdfDocument(); doc.Info.Title = "DayPilot Calendar PDF Export"; doc.Info.Author = "DayPilot"; // add a page PdfPage page = doc.AddPage(); // set PDF page properties (size and orientation) page.Size = (PageSize) Enum.Parse(typeof (PageSize), ListPageSize.SelectedValue); page.Orientation = (PageOrientation)Enum.Parse(typeof(PageOrientation), ListPageOrientation.SelectedValue); // create graphics object for PDF page modification XGraphics gfx = XGraphics.FromPdfPage(page); // write title XRect titleRect = new XRect(new XPoint(), gfx.PageSize); titleRect.Inflate(-10, -15); XFont font = new XFont("Tahoma", 14, XFontStyle.Bold); gfx.DrawString("DayPilot Calendar PDF Export", font, XBrushes.DarkGray, titleRect, XStringFormats.TopCenter); // create event calendar image SetDataSourceAndBind(); SetExportProperties(); Bitmap bitmap = DayPilotCalendar1.ExportBitmap(); // add the image to the PDF page XImage image = XImage.FromGdiPlusImage(bitmap); XRect imageRect = GetPaddedRectForImage(gfx, image, 10); double y = 40; imageRect.Y = y; gfx.DrawImage(image, imageRect); // save the PDF file to MemoryStream MemoryStream mem = new MemoryStream(); doc.Save(mem, false); // send the output stream to the browser Response.Clear(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=calendar.pdf"); mem.WriteTo(Response.OutputStream); Response.End(); } private XRect GetPaddedRectForImage(XGraphics gfx, XImage image, int paddingWidthPct) { double ratio = image.PixelWidth / (double)image.PixelHeight; double width = gfx.PageSize.Width; double height = width / ratio; XRect imageRect = new XRect(0, 0, width, height); imageRect.Scale((100 - paddingWidthPct) / 100.0, (100 - paddingWidthPct) / 100.0); double x = (gfx.PageSize.Width - imageRect.Width) / 2; imageRect.X = x; return imageRect; }
VB
Private Sub ExportToPdf() ' create a new PDF document Dim doc As New PdfDocument() doc.Info.Title = "DayPilot Calendar PDF Export" doc.Info.Author = "DayPilot" ' add a page Dim page_Renamed As PdfPage = doc.AddPage() ' set PDF page properties (size and orientation) page_Renamed.Size = CType(System.Enum.Parse(GetType(PageSize), ListPageSize.SelectedValue), PageSize) page_Renamed.Orientation = CType(System.Enum.Parse(GetType(PageOrientation), ListPageOrientation.SelectedValue), PageOrientation) ' create graphics object for PDF page modification Dim gfx As XGraphics = XGraphics.FromPdfPage(page_Renamed) ' write title Dim titleRect As New XRect(New XPoint(), gfx.PageSize) titleRect.Inflate(-10, -15) Dim font As New XFont("Tahoma", 14, XFontStyle.Bold) gfx.DrawString("DayPilot Calendar PDF Export", font, XBrushes.DarkGray, titleRect, XStringFormats.TopCenter) ' create event calendar image SetDataSourceAndBind() SetExportProperties() Dim bitmap As Bitmap = DayPilotCalendar1.ExportBitmap() ' add the image to the PDF page Dim image As XImage = XImage.FromGdiPlusImage(bitmap) Dim imageRect As XRect = GetPaddedRectForImage(gfx, image, 10) Dim y As Double = 40 imageRect.Y = y gfx.DrawImage(image, imageRect) ' save the PDF file to MemoryStream Dim mem As New MemoryStream() doc.Save(mem, False) ' send the output stream to the browser Response.Clear() Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=calendar.pdf") mem.WriteTo(Response.OutputStream) Response.End() End Sub Private Function GetPaddedRectForImage(ByVal gfx As XGraphics, ByVal image As XImage, ByVal paddingWidthPct As Integer) As XRect Dim ratio As Double = image.PixelWidth / CDbl(image.PixelHeight) Dim width As Double = gfx.PageSize.Width Dim height As Double = width / ratio Dim imageRect As New XRect(0, 0, width, height) imageRect.Scale((100 - paddingWidthPct) / 100.0, (100 - paddingWidthPct) / 100.0) Dim x As Double = (gfx.PageSize.Width - imageRect.Width) \ 2 imageRect.X = x Return imageRect End Function