This is a migrated thread and some comments may be shown as answers.

Create a pdf in landscape/horizontal view

4 Answers 203 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Phil
Top achievements
Rank 1
Phil asked on 04 Feb 2015, 10:41 PM
Hello all, i was wondering if anybody could help me figure out how to take the current week view in the scheduler and create a pdf that's in a landscape/horizontal view of it?

Thanks all,

Phil

4 Answers, 1 is accepted

Sort by
0
Accepted
Hristo
Telerik team
answered on 06 Feb 2015, 03:40 PM
Hi Phil,

Thank you for writing.

You can achieve this task by creating an image out of the current week view and then with the help of our RadPdfProcessing framework export the image to a pdf document. Please see my example below:
private void createPdfButton_Click(object sender, EventArgs e)
{
    this.radScheduler1.ActiveViewType = SchedulerViewType.Week;
    SchedulerWeekView weekView = this.radScheduler1.GetWeekView();
    weekView.StartDate = DateTime.Now;
 
    Application.DoEvents();
    Bitmap bitmap = new Bitmap(this.radScheduler1.Width, this.radScheduler1.Height);
    weekView.Scheduler.DrawToBitmap(bitmap, new Rectangle(0, 0, weekView.Scheduler.Width, weekView.Scheduler.Height));
    bitmap.Save(@"..\..\current-week.png", ImageFormat.Png);
 
    Telerik.Windows.Documents.Fixed.Model.RadFixedDocument document = new Telerik.Windows.Documents.Fixed.Model.RadFixedDocument();
    Telerik.Windows.Documents.Fixed.Model.RadFixedPage page = new Telerik.Windows.Documents.Fixed.Model.RadFixedPage();
    document.Pages.Add(page);
 
    Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource imageSource;
    using (FileStream source = File.Open(@"..\..\current-week.png", FileMode.Open))
    {
        imageSource = new Telerik.Windows.Documents.Fixed.Model.Resources.ImageSource(source);
    }
    Telerik.Windows.Documents.Fixed.Model.Objects.Image imageWithSource = page.Content.AddImage(imageSource);
    System.Windows.Size pageSize = new System.Windows.Size(imageSource.Width, imageSource.Height);
    page.Size = pageSize;
 
    Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider provider = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.PdfFormatProvider();
    Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExportSettings settings = new Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.PdfExportSettings();
    settings.ImageQuality = Telerik.Windows.Documents.Fixed.FormatProviders.Pdf.Export.ImageQuality.High;
    provider.ExportSettings = settings;
    using (FileStream output = new FileStream(@"..\..\current-week.pdf", FileMode.Create))
    {
        provider.Export(document, output);
    }
}

I am sending you attached the exported file using the code above.

I hope this information is useful. Should you have further questions please do not hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Phil
Top achievements
Rank 1
answered on 06 Feb 2015, 10:30 PM
Thanks Hristo, that worked out great!

Phill
0
Art
Top achievements
Rank 1
answered on 17 Feb 2015, 08:28 PM
Can you do that same thing with a SchedulerWeeklyCalendarView? And also, how do I edit the ruler, or add notes, or change the heading. In VB.Net please.
0
Hristo
Telerik team
answered on 19 Feb 2015, 08:08 AM
Hi Art,

Thank you for writing.

If I understand you correctly you are asking if the suggested approach is valid for any of the other views. If that is the case, the answer is yes. You can find additional information for the specifics of each individual view in the articles in this section of our documentation. If that is not the case please clarify what you mean by SchedulerWeeklyCalendarView since we do not have a view nor a class with that name.

As to your second question, the best place to perform this type of operation is in the Formatting events.
Regarding the header cells I can recommend subscribing to the CellFormatting event, you can examine a sample implementation here. Considering the RulerPrimitive, the appropriate event is RulerTextFormatting, an example is discussed here.

I hope this information is useful. Should you have further questions please do no hesitate to write back.

Regards,
Hristo Merdjanov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Scheduler and Reminder
Asked by
Phil
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Phil
Top achievements
Rank 1
Art
Top achievements
Rank 1
Share this question
or