Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
675
Printing complete day (or at least working hours) from XamOutlookView
posted

I'm using XamOutlookView for a scheduling application and it is really working great! My customers are quite happy with it. I do however have a small problem. I'd like to print the schedule for the day or week and haven't figured out how to do it.

It is possible to add the on screen view to the report like this: EmbeddedVisualReportSection section = new EmbeddedVisualReportSection(MyOutlookView);

but that only shows what is on the screen. We need it to show at least all the working hours.

What is the best way to accomplish this?

Thanks!

Parents
No Data
Reply
  • 675
    Verified Answer
    posted

    This code allows you to do what I was asking. Simply call the Print() method and pass it the XamOutlookCalendarView.

    code is borrowed from http://stackoverflow.com/questions/7931961/wpf-printing-to-fit-page

    private void Print(Visual v)
    {

    System.Windows.FrameworkElement e = v as System.Windows.FrameworkElement;
    if (e == null)
    return;

    PrintDialog pd = new PrintDialog();
    if (pd.ShowDialog() == true)
    {
    //store original scale
    Transform originalScale = e.LayoutTransform;
    //get selected printer capabilities
    System.Printing.PrintCapabilities capabilities = pd.PrintQueue.GetPrintCapabilities(pd.PrintTicket);

    //get scale of the print wrt to screen of WPF visual
    double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / e.ActualWidth, capabilities.PageImageableArea.ExtentHeight /
    e.ActualHeight);

    //Transform the Visual to scale
    e.LayoutTransform = new ScaleTransform(scale, scale);

    //get the size of the printer page
    System.Windows.Size sz = new System.Windows.Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

    //update the layout of the visual to the printer page size.
    e.Measure(sz);
    e.Arrange(new System.Windows.Rect(new System.Windows.Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));

    //now print the visual to printer to fit on the one page.
    pd.PrintVisual(v, "Epi-flex Dispatcher");

    //apply the original transform.
    e.LayoutTransform = originalScale;
    }
    }

Children
No Data