heyin365 发表于 2018-3-7 15:02:11

WPF 代码 自动打印 为空白

以下为我的WPF 两种打印方式
打出来都是空白板 ,没有任何内容

是不是先要预加载呢?


/// <summary>
      /// 加载订单详情报表
      /// </summary>
      public void LoadOrderReport(Guid pOrderID, string pPrinterName)
      {
            PageReport pageReport = new PageReport(new FileInfo(_currentFileLocation));
            if (pageReport != null)
            {
                foreach (var dataSource in report.Report.DataSources)
                {
                  dataSource.ConnectionProperties.DataProvider = "ODBC";
                  dataSource.ConnectionProperties.ConnectString = ExpressionInfo.FromString(AppConfigUtils.GetReportConnectionString());
                }
                pageReport.Report.ReportParameters.DefaultValue.Values.Clear();
                pageReport.Report.ReportParameters.DefaultValue.Values.Add(pOrderID.ToString());

                //第一种打印
                //GrapeCity.ActiveReports.Document.PageDocument pageDocument = new GrapeCity.ActiveReports.Document.PageDocument(report);
                //pageDocument.Printer.PrinterName = _printerName;
                //pageDocument.Printer.Print();

                //第二种打印
                pageReport.Document.Printer.PrinterName = _printerName;
                pageReport.Document.Printer.Print();            
            }

      }

KearneyKang 发表于 2018-3-7 15:08:06

本帖最后由 KearneyKang 于 2018-3-7 15:49 编辑


您好WPF的打印只能用这种办法实现打印private void Button1_Click(object sender, RoutedEventArgs e)
      {
            viewr1.Print(true, true, false);
      }

页: [1]
查看完整版本: WPF 代码 自动打印 为空白