我正在尝试使用 WPF 的PrintDialog
类(PresentationFramework.dll 中的命名空间 System.Windows.Controls,v4.0.30319)进行打印。这是我使用的代码:
private void PrintMe()
{
var dlg = new PrintDialog();
if (dlg.ShowDialog() == true)
{
dlg.PrintVisual(new System.Windows.Shapes.Rectangle
{
Width = 100,
Height = 100,
Fill = System.Windows.Media.Brushes.Red
}, "test");
}
}
问题是无论我为“Microsoft XPS Document Writer”选择什么纸张尺寸,生成的 XPS 始终具有“ Letter ”纸张类型的宽度和高度:
这是我可以在 XPS 包中找到的 XAML 代码:
<FixedPage ... Width="816" Height="1056">