wpf打印屏幕

时间:2011-11-10 20:00:43

标签: wpf printing c#-3.0

我有一个要转储到打印机的WPF窗口。我找到了这个代码,这是一个很好的开始,但它有一些问题,我不知道我在做什么。

PrintDialog printDialog = new PrintDialog ( );
if ( printDialog.ShowDialog ( ) == true )
{
    PrintCapabilities capabilities = printDialog.PrintQueue.GetPrintCapabilities ( printDialog.PrintTicket );

    double scale = Math.Min ( capabilities.PageImageableArea.ExtentWidth / this.ActualWidth,
        capabilities.PageImageableArea.ExtentHeight / this.ActualHeight );

    this.LayoutTransform = new ScaleTransform ( scale, scale );
    Size size = new Size ( capabilities.PageImageableArea.ExtentWidth, capabilities.PageImageableArea.ExtentHeight );

    this.Measure ( size );
    this.Arrange ( new Rect 
        ( new Point ( capabilities.PageImageableArea.OriginWidth, capabilities.PageImageableArea.OriginHeight ), 
            size ) );

    printDialog.PrintVisual ( this, "Well Information" );
}

我正在打印到常规的8.5x11页面,肖像。我得到的是一个大约9英寸高的页面(顶部和底部有大约1英寸的灰色条带)和大约一半的屏幕(从左到右)。理想情况下,我想要的是横向打印(默认情况下,我意识到用户可以更改),显示所有屏幕,并根据需要进行缩放。

0 个答案:

没有答案