2

Iam new in WPF application development. I want to print the contents of a form to printer. I have following code

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);
}

I have used a pdf printer for printing document. I got pdf like this enter image description here

I need to add a border to this print. is it possible to design printing output using this way?

Abdul Manaf
  • 4,933
  • 8
  • 51
  • 95

0 Answers0