基于代码的区域报表打印问题
打印的时候更改打印机会默认成信纸而不是页面设置的纸张大小页面打印的时候纸张需要进行选择,正常默认情况下是A4纸。点击打印都会弹出一个打印选择框,进行纸张和打印模式的选择。你是B/s端的项目还是C/端的项目 KearneyKang 发表于 2018-7-31 16:39
页面打印的时候纸张需要进行选择,正常默认情况下是A4纸。点击打印都会弹出一个打印选择框,进行纸张和打印 ...
默认是C/S的,如果把打印机设置成默认打印机没有问题,果然不设置默认打印机更换打印机时候必须要手动设置纸张,要不就不对。有没有给报表设置打印机的方法 报表没办法设置打印机,但是你可以通过自己受到添加打印按钮,然后在打印按钮里直接设置对应的打印机,进行打印机的默认。
具体你可以参考参考模板库里打印的demo:https://gcdn.grapecity.com.cn/forum.php?mod=viewthread&tid=48785&extra=page%3D1
下面是打印的核心代码,然后强制设置打印机的命名,如果是网络打印机则设置打印机如下网络命名,如 “\\xa-printer.Net\打印机名”
private void tsbPrint_Click(object sender, EventArgs e)
{
string file_name = @"..\..\RdlReport1.rdlx";
GrapeCity.ActiveReports.PageReport pageReport = new GrapeCity.ActiveReports.PageReport(new System.IO.FileInfo(file_name));
pageReport.Document.LocateDataSource += new LocateDataSourceEventHandler(LocateData);
pageReport.Document.Printer.DefaultPageSettings.Margins.Bottom = 0;
pageReport.Document.Printer.DefaultPageSettings.Margins.Left = 0;
pageReport.Document.Printer.DefaultPageSettings.Margins.Right = 0;
pageReport.Document.Printer.DefaultPageSettings.Margins.Top = 0;
pageReport.Document.Printer.PaperSize.RawKind = 0;
pageReport.Document.Printer.PaperSize.Width = 14;
pageReport.Document.Printer.PaperSize.Height = 20;
pageReport.Document.Printer.PrinterName = "";
GrapeCity.ActiveReports.PrintExtension.Print(_document, true, true);
}
页:
[1]