search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Scheduler export date range problems

Asked by Ed
5 days ago.

Hi,

Using Web forms scheduler and I have it set up to advance or retreat +- 3 months using the “Previous/Next” examples found throughout the forums. The +- navigation works as expected; my timeline advances or retracts by 3 months. I also have Day/Week views using similarly found examples…working fine as well. I’ve now added export to PDF but if I do scale by week or move the timeline via Previous/Next the export still only shows the date current date range.

For example, my scale by week option shows a year’s worth of events (ex. Mar2024-Mar2025) but when I export I only get Dec2024-Feb6 which matches my default date range. In the sub that calls the export I am setting start date and days (using visible start and visible end…not certain that’s how it works - image attached) but still only get the default date range. The same thing occurs when I’m scaling in day mode and use “Previous/Next”.

What am I doing wrong? Thanks….

Answer posted by Dan Letecky [DayPilot]
3 days ago.

By default, the exportAs() method includes the current viewport in the exported image.

You can use the area property of the options parameter to include the full timeline (area: "full") or a manually-specified date range (area: "range").

This lets you export the Scheduler grid as multiple images (for paged PDF export). See also the following tutorials:

Comment posted by Ed
3 days ago.

Copy and thanks for the feedback. In looking at your example it seems to be client-side based - how would it translate to server-side exporting? Please review the following code, partially derived from one of the examples: 

Private Sub ExportToPdf2()

        Dim doc As PdfDocument = New PdfDocument()

        Dim bitmap As Bitmap = Dps_Scv.ExportBitmap()

        ' add the image to the PDF page

        Dim img As XImage = XImage.FromGdiPlusImage(bitmap)

 

       'these numbers are guesswork but for an 11x17 landscape format get the closest thing to a good output.

        Dim captureHeight As Double = 760

        Dim captureWidth As Double = 2510

        Dim totalHeight As Double = img.PixelHeight / 1.5

        Dim totalWidth As Double = img.PixelWidth

 

        Dim page As PdfPage = Nothing

        Dim i = 0

        Dim saveHeight As Double = 0

        While saveHeight < totalHeight

            page = New PdfPage()

            page.Size = PdfSharp.PageSize.Tabloid

            page.Orientation = PdfSharp.PageOrientation.Landscape

            doc.Pages.Add(page)

 

            Dim xgr As XGraphics = XGraphics.FromPdfPage(doc.Pages(i))

            xgr.DrawImage(img, 0, -i * captureHeight, captureWidth, totalHeight)

            saveHeight += captureHeight

            i += 1

        End While

        ' 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=staffview.pdf")

        mem.WriteTo(Response.OutputStream)

        Response.End()

    End Sub

 

In the example (which again is a combo of DayPilot example code and kludges that I found on a PDF Sharp forum for multiple page printing of an exported image), the scheduler is being captured as a bitmap and then various pdf sharp methods are being used to format the output, ultimately being streamed to the browser as a pdf. It works, but not without issues, etc. and I don’t think it will scale well.

Can the “ExportAs” functionality be adapted to a server-side model? If so, are there any examples in the docs? On a whim, I tried using ExportAs in my code-behind but I’m getting a VS error about ExportAs not being a member of DayPilotScheduler (screenshot attached).

So guessing that it can’t be directly leveraged from server-side code – any suggestions?

Thanks again - Ed

Comment posted by Dan Letecky [DayPilot]
2 days ago.

On the server side, it is necessary to use Export() or ExportBitmap() methods (see Server-Side Image Export in the documentation).

To limit the exported range, you can set StartDate, Days and Resources properties as needed before calling Export().

New Reply
This reply is
Attachments:
or drop files here
Your name (optional):