.net WPF打印中的用户定义页边距
WPF的大多数打印示例如下所示:.net WPF打印中的用户定义页边距,.net,wpf,printing,margin,.net,Wpf,Printing,Margin,WPF的大多数打印示例如下所示: PrintDialog dialog = new PrintDialog(); if (dialog.ShowDialog() == true) { StackPanel myPanel = new StackPanel(); myPanel.Margin = new Thickness(15); Image myImage = new Image(
PrintDialog dialog = new PrintDialog();
if (dialog.ShowDialog() == true)
{
StackPanel myPanel = new StackPanel();
myPanel.Margin = new Thickness(15);
Image myImage = new Image();
myImage.Width = dialog.PrintableAreaWidth;
myImage.Stretch = Stretch.Uniform;
myImage.Source = new BitmapImage(new Uri("pack://application:,,,/Images/picture.bmp"));
myPanel.Children.Add(myImage);
myPanel.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
myPanel.Arrange(new Rect(new Point(0, 0), myPanel.DesiredSize));
dialog.PrintVisual(myPanel, "A Great Image.");
}
我不喜欢的是,他们总是将边距设置为固定值。
但在PrintDialog中,用户可以选择一个样本不关心的单独页边距。如果用户现在选择的边距大于程序设置的固定边距,则打印输出将被截断。
有没有办法从PrintDialog获取用户选择的边距值
短暂性脑缺血发作
Michael我非常确定您在PrintDialog中更改的边距是打印机驱动程序特定的设置。无法从.NET访问该设置是正常的。我确信您在PrintDialog中更改的边距是打印机驱动程序特定的设置。无法从.NET访问设置是正常的。我找到了一个解决方案:PrintDocumentImageableArea=null;XpsDocumentWriter xpsdw=PrintQueue.CreateXpsDocumentWriterref区域;边距位于区域对象中。但这总是会打开打印对话框,也许我找到了一些方法,可以在不打开对话框的情况下获得默认页边距;XpsDocumentWriter xpsdw=PrintQueue.CreateXpsDocumentWriterref区域;边距位于区域对象中。但这总是会打开打印对话框,也许我会找到一些方法,在不打开对话框的情况下获取默认页边距。