[英]How to display a window half of its original size
I'm printing a WPF window in A4, so originally the window size is rather big. 我正在A4中打印WPF窗口,因此最初的窗口大小很大。 I would like to display it half the size of the original without modifying the printing output. 我想将其显示为原始尺寸的一半,而不修改打印输出。 Any ideas? 有任何想法吗?
This is my method where I print 这是我打印的方法
private void printItemList(string printerName)
{
//printButton.Visibility = Visibility.Collapsed;
//cancelButton.Visibility = Visibility.Collapsed;
PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
printDlg.PrintQueue = new System.Printing.PrintQueue(new System.Printing.PrintServer(), printerName);
System.Printing.PrintCapabilities capabilities = printDlg.PrintQueue.GetPrintCapabilities(printDlg.PrintTicket);
//get scale of the print wrt to screen of WPF visual
double scale = Math.Min(capabilities.PageImageableArea.ExtentWidth / this.ActualWidth, capabilities.PageImageableArea.ExtentHeight /
this.ActualHeight);
//Transform the Visual to scale
this.LayoutTransform = new ScaleTransform(scale, scale);
//get the size of the printer page
Size sz = new Size(this.ActualWidth, this.ActualHeight); //(8.5 * 96.0, 11.0 * 96.0);
//update the layout of the visual to the printer page size.
this.Measure(sz);
this.Arrange(new Rect(new Point(capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight), sz));
//now print the visual to printer to fit on the one page.
printDlg.PrintVisual(this, "Print Page");
this.DialogResult = true;
}
ViewBox does what I was thinking, I just have to make sure it is resized before printing executed. ViewBox可以实现我的想法,我只需要确保在执行打印之前调整其大小即可。 Thanks for the tip. 谢谢你的提示。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.