预览看着正常。代码中也没设置什么边距。
打印代码:
/// <summary>
/// 多参数指定打印机名打印
/// </summary>
/// <param name="reportFilePath">报表文件路径</param>
/// <param name="reportJsons">Json数据</param>
/// <param name="printerName">打印机名</param>
static public void NowPrint(string reportFilePath, List<string> reportJsons, string printerName)
{
PageReport pageReport = new PageReport(new FileInfo(reportFilePath));
PageDocument pageDocument = new PageDocument(pageReport);
for (int i = 0; i < reportJsons.Count; i++)
{
pageReport.Report.DataSources.ConnectionProperties.ConnectString = "jsondata=" + reportJsons;
}
pageDocument.Printer.PrinterName = printerName;
Viewer viewer = new Viewer();
viewer.LoadCompleted += view_LoadCompleted;
viewer.LoadDocument(pageDocument);
}
#endregion
#region 加载完报表文件直接打印
static private void view_LoadCompleted(object sender, EventArgs e)
{
((Viewer)sender).Print(false, false, true);
}
#endregion
|