Click here to Skip to main content
15,900,108 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i found this how can i call this

private void Print(Visual v)
       {

           FrameworkElement e = v as FrameworkElement;
           if (e == null)
               return;

           PrintDialog pd = new PrintDialog();
           if (pd.ShowDialog() == true)
           {
               //store original scale
               Transform originalScale = e.LayoutTransform;
               //get selected printer capabilities
               var 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
               Size sz = new Size(capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight);

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

               //now print the visual to printer to fit on the one page.
               pd.PrintVisual(v, "My Print");

               //apply the original transform.
               e.LayoutTransform = originalScale;
           }
       }
Posted
Updated 9-Aug-13 11:19am
v2
Comments
[no name] 9-Aug-13 20:25pm    
Your question is "How do I call a function"?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900