打印功能
Posted lvlaozf
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了打印功能相关的知识,希望对你有一定的参考价值。
第一种方法:
DevExpress.XtraPrinting.DynamicPrintHelper ph = new DevExpress.XtraPrinting.DynamicPrintHelper();
if (ph.IsPrintingAvailable)
{
ph.PageSettings = set_print_page;
ph.PageSettings.Landscape = true;
ph.ShowPreview(this.gc, true);
}
第二种方法:
{
DataRowView drv = (DataRowView)BS_Roads.Current;
PrintingSystem ps = new PrintingSystem();
PrintableComponentLink link = new PrintableComponentLink(ps);
link.Component = gc;
link.Landscape = true;
PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter;
phf.Header.Content.Clear();
phf.Header.Content.AddRange(new string[] { "", drv["线路名"].ToString() + "站点信息表", "" });
phf.Header.Font = new System.Drawing.Font("宋体", 16, System.Drawing.FontStyle.Regular);
phf.Header.LineAlignment = BrickAlignment.Center;
phf.Footer.Content.Clear();
phf.Footer.Content.AddRange(new string[] { "", String.Format("打印时间: {0:g}", DateTime.Now), "" });
link.CreateDocument();
link.ShowPreview();
}
else
{
XtraMessageBox.Show("打印机不可用...", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
#region 水印图片
reportPrint.ShowPrintStatusDialog = false;
#endregion
PrintableComponentLink printLink = new PrintableComponentLink(reportPrint);
reportPrint.Links.Add(printLink);
printLink.Component = sheet;//这里可以是可打印的部件
#region 报表的页眉页脚的设置
PageHeaderFooter phf = printLink.PageHeaderFooter as PageHeaderFooter;
phf.Header.Content.Clear();
phf.Header.Content.AddRange(new string[] { "", printHeader, "" });
phf.Header.Font = new System.Drawing.Font("微软雅黑", 14, System.Drawing.FontStyle.Bold);
phf.Header.LineAlignment = BrickAlignment.Center;
phf.Footer.Content.Clear();
phf.Footer.Content.AddRange(new string[] { "", "", "第[页#]页 共 [页 #]页" });
#endregion
以上是关于打印功能的主要内容,如果未能解决你的问题,请参考以下文章