- private void ButtonParamPrint_Click(object sender, EventArgs e)
- {
- List<Dictionary<string, object>> dataList = GetDataTable();
- PageReport report = new(new FileInfo(FileName));
- foreach (Dictionary<string, object> map in dataList)
- {
- /*参数传入*/
- report.Report.ReportParameters[0].DefaultValue.Values.Clear();
- report.Report.ReportParameters[0].DefaultValue.Values.Add(map["GUID"].ToString());
- report.Report.ReportParameters[1].DefaultValue.Values.Clear();
- report.Report.ReportParameters[1].DefaultValue.Values.Add(map["cCmpCode"].ToString());
- report.Run();
- PageDocument document = report.Document;
- if (document != null)
- {
- /*参数设置*/
- Printer printer = document.Printer;
- printer.DefaultPageSettings.Margins.Bottom = 0;
- printer.DefaultPageSettings.Margins.Left = 0;
- printer.DefaultPageSettings.Margins.Right = 0;
- printer.DefaultPageSettings.Margins.Top = 0;
- //printer.DefaultPageSettings.PaperSize.Width = 8;
- //printer.DefaultPageSettings.PaperSize.Height = 5;
- printer.DefaultPageSettings.Landscape = true;
- printer.Landscape = true;
- document.Print(true, true, false);
- }
- else
- {
- Debug.WriteLine("---------------------------------END--------------->" + document!.Parameters.Count);
- }
- }
复制代码 当前代码是对数据进行指定 rdlx 打印。
执行时总是需要手动选择 高级属性 自动旋转
否则打印标签就会出现异常如下
|