In my windows form, I have the following method to print out word documents when the printDocument1.Print() statement is called:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
float yPos = 0;
float lines = e.MarginBounds.Height / font.GetHeight(e.Graphics);
int count = 0;
string line = null;
while ((count < lines) && ((line = reader.ReadLine()) != null))
{
yPos = topMargin + (count * font.GetHeight(e.Graphics));
e.Graphics.DrawString(line, font, Brushes.Black, leftMargin, yPos, new StringFormat());
count++;
}
if (line != null)
e.HasMorePages = true;
else
e.HasMorePages = false;
}
The problem is the printed document shows something like the following besides the content of the file:
[][][][][][][][][][][][][][][]>[][][][][][][][][][][][][]*
[][][][][]F[][][][][]b[][][][][][][][][][]0[][]F[][]q[][][]
etc., where the [] shows in the printed document as squares. The word macros that I wrote and other data such as HelpContextID that I don't know where they came from also show in the printed document.
Does anyone know know to fix this?
Thanks.
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
float leftMargin = e.MarginBounds.Left;
float topMargin = e.MarginBounds.Top;
float yPos = 0;
float lines = e.MarginBounds.Height / font.GetHeight(e.Graphics);
int count = 0;
string line = null;
while ((count < lines) && ((line = reader.ReadLine()) != null))
{
yPos = topMargin + (count * font.GetHeight(e.Graphics));
e.Graphics.DrawString(line, font, Brushes.Black, leftMargin, yPos, new StringFormat());
count++;
}
if (line != null)
e.HasMorePages = true;
else
e.HasMorePages = false;
}
The problem is the printed document shows something like the following besides the content of the file:
[][][][][][][][][][][][][][][]>[][][][][][][][][][][][][]*
[][][][][]F[][][][][]b[][][][][][][][][][]0[][]F[][]q[][][]
etc., where the [] shows in the printed document as squares. The word macros that I wrote and other data such as HelpContextID that I don't know where they came from also show in the printed document.
Does anyone know know to fix this?
Thanks.