Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/301.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.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
C# WPF打印在1个系统上打印,而不是在其他系统上打印_C#_Wpf_Printing - Fatal编程技术网

C# WPF打印在1个系统上打印,而不是在其他系统上打印

C# WPF打印在1个系统上打印,而不是在其他系统上打印,c#,wpf,printing,C#,Wpf,Printing,我有一个WPF应用程序,其中有3种打印形式。通过两种方式,我直接使用窗口的视觉效果,并使用PrintVisualmyPanel、Title打印它。第三步,我需要打印多个页面,所以我使用了FlowDocument、StackPanel和IDocumentPaginatorSource,并调用PrintDocument进行打印 所有的代码在我的系统上都运行得很好。我可以在OneNote和XPS上执行打印,它可以正常工作。但同一个应用程序,当我尝试在其他系统上运行时,它会显示所有3个打印的空白页面。P

我有一个WPF应用程序,其中有3种打印形式。通过两种方式,我直接使用窗口的视觉效果,并使用PrintVisualmyPanel、Title打印它。第三步,我需要打印多个页面,所以我使用了FlowDocument、StackPanel和IDocumentPaginatorSource,并调用PrintDocument进行打印

所有的代码在我的系统上都运行得很好。我可以在OneNote和XPS上执行打印,它可以正常工作。但同一个应用程序,当我尝试在其他系统上运行时,它会显示所有3个打印的空白页面。PrintVisual在.NET 3.0、3.5、4.0、4.5上受支持,因此我找不到它不工作的原因

为了更清晰,我还将分享我的一些代码:

    // 1 PRINT 
    public void PrintRegister()
    {
        PrintDialog pd = new PrintDialog();
        if (pd.ShowDialog() == true)
            pd.PrintVisual(this, "Register Window");

        return;
    }

    // 2 PRINT  
    public static void PrintAttendanceOf(System.Data.DataRow r1) {
        PrintLayoutWindowPORT plw = PrintUtility.CreatePrintLayoutWindowPORTObject(r1); // PORTRAIT

        Canvas p1 = PrintUtility.CloneCanvas(plw._PrintCanvas, 5);
        Grid myPanel = new Grid();
        myPanel.Margin = new Thickness(10);
        myPanel.Children.Add(p1);

        PrintDialog pd = new PrintDialog();
        pd.PageRangeSelection = PageRangeSelection.AllPages;
        PrintQueue pq = pd.PrintQueue;
        pq.DefaultPrintTicket.PageOrientation = PageOrientation.Portrait;
        pd.PrintTicket = pq.DefaultPrintTicket;

        double pageWidth = pd.PrintableAreaWidth;
        double pageHeight = pd.PrintableAreaHeight;

        myPanel.Measure(new Size(pageWidth, pageHeight));
        //myPanel.Arrange(new Rect(new Point(1, 1), myPanel.DesiredSize));
        myPanel.UpdateLayout();

        if (pd.ShowDialog().GetValueOrDefault(false))
        {
            pd.PrintVisual(myPanel, "Attendance Chart");
        }

        pd = null;
        plw.Close();
        plw = null;
        myPanel = null;
        p1 = null;

        return;
    }
第三次打印(即多页)的代码很长,因此现在没有在此处添加。如果需要,您可以发布它

有人能帮我知道为什么在其他系统上打印空白页而没有内容吗。我觉得可能需要某种兼容性、系统或资源,或者其他什么

非常感谢您的帮助

谢谢