Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WPF打印中的用户定义页边距_.net_Wpf_Printing_Margin - Fatal编程技术网

.net 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(

WPF的大多数打印示例如下所示:

        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区域;边距位于区域对象中。但这总是会打开打印对话框,也许我会找到一些方法,在不打开对话框的情况下获取默认页边距。