如何在PrintDocument C#中添加边框

时间:2018-08-30 04:38:23

标签: c# .net wpf graphics printdocument

我是WPF应用程序开发中的新手。我想将表格的内容打印到打印机。我有以下代码

string s = "Name : Test" + Environment.NewLine +
                    "Age : 25" + Environment.NewLine +
                    "Sex : Male" + Environment.NewLine;

PrintDocument p = new PrintDocument();
p.PrintPage += delegate (object sender1, PrintPageEventArgs e1)
                {
                    e1.Graphics.DrawString(s, new Font("Times New Roman", 12), new SolidBrush(System.Drawing.Color.Black), new RectangleF(0, 0, p.DefaultPageSettings.PrintableArea.Width, p.DefaultPageSettings.PrintableArea.Height));
};
try
{
  p.Print();
}
catch (Exception ex)
{
   throw new Exception("Exception Occured While Printing", ex);
}

我已使用pdf打印机打印文档。我有这样的pdf enter image description here

我需要在此打印上添加边框。这样可以设计打印输出吗?

0 个答案:

没有答案