"PrintVisual wpf scale" Code Answer's
You're definitely familiar with the best coding language C# that developers use to develop their projects and they get all their queries like "PrintVisual wpf scale" answered properly. Developers are finding an appropriate answer about PrintVisual wpf scale related to the C# coding language. By visiting this online portal developers get answers concerning C# codes question like PrintVisual wpf scale. Enter your desired code related query in the search bar and get every piece of information about C# code related question on PrintVisual wpf scale.
PrintVisual wpf scale
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, "My Print");
//apply the original transform.
e.LayoutTransform = originalScale;
}
}
Source: stackoverflow.com
All those coders who are working on the C# based application and are stuck on PrintVisual wpf scale can get a collection of related answers to their query. Programmers need to enter their query on PrintVisual wpf scale related to C# code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about PrintVisual wpf scale for the programmers working on C# code while coding their module. Coders are also allowed to rectify already present answers of PrintVisual wpf scale while working on the C# language code. Developers can add up suggestions if they deem fit any other answer relating to "PrintVisual wpf scale". Visit this developer's friendly online web community, CodeProZone, and get your queries like PrintVisual wpf scale resolved professionally and stay updated to the latest C# updates.