【发布时间】:2015-12-20 15:24:23
【问题描述】:
我正在尝试通过将高度和宽度分别设置为 29.7 厘米和 21 厘米来打印 A4 尺寸的画布。
我在 Windows 7 设备上获得了正确的输出。但对于 Windows 10 设备,打印输出与 Windows 7 设备不同。
真正的问题是没有为 Windows 10 设备维护高度和宽度。
请帮助和建议我!!
请查看以下代码:
Xaml:
<Window x:Class="TestSolution.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
Height="29.7cm"
Width="21cm"
ResizeMode="NoResize">
<Grid x:Name="grdTest"
VerticalAlignment="Stretch"
HorizontalAlignment="Stretch"
Height="29.7cm"
Width="21cm">
<Canvas x:Name="cnvTest"
VerticalAlignment="Stretch"
Height="29.7cm"
Width="21cm"
HorizontalAlignment="Stretch">
</Canvas>
</Grid>
</window>
代码背后
private void btn_Click(object sender, RoutedEventArgs e)
{
PrintDialog prnt = new PrintDialog();
if (prnt.ShowDialog() == true)
{
prnt.PrintVisual(cnvTest, "Printing Canvas");
}
this.Close();
}
【问题讨论】: