我有WPF窗口,我想打印纸张尺寸4英寸6英寸。我有WPF窗口,我想打印在纸张尺寸** 4英寸6英寸**
我不明白在哪里设置这个尺寸? 我使用窗口大小打印,但窗口大小不起作用。 我的打印机没有固定纸张尺寸。
这是我的打印代码:
private void _print()
{
PrintDialog printDlg = new System.Windows.Controls.PrintDialog();
//printDlg.ShowDialog();
//get selected printer capabilities
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);
//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");
}
尝试设置'printDlg.PrintTicket.PageMediaSize' – Nitin
@nit:但是如何设置页面中英寸?我有窗口大小高度=“490”宽度=“410”。 –
请参阅我的回答 – Nitin