private void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null; linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics); //开始打印标题(占两行)
ev.Graphics.DrawString(title, printFont, Brushes.Black, leftMargin, topMargin, new StringFormat());
count = 2;
//打印内容
while (count < linesPerPage &&
((line = streamToPrint.ReadLine()) != null))
{
yPos = topMargin + ( count * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,leftMargin, yPos, new StringFormat());
count++;
}
// If more lines exist, print another page.
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
当LINE中有"\t"是打印机会忽列,怎样让打印机遇到"\t"是跳到下一列打印?
如解决,立马结贴(本人在线等).
{
float linesPerPage = 0;
float yPos = 0;
int count = 0;
float leftMargin = ev.MarginBounds.Left;
float topMargin = ev.MarginBounds.Top;
string line = null; linesPerPage = ev.MarginBounds.Height / printFont.GetHeight(ev.Graphics); //开始打印标题(占两行)
ev.Graphics.DrawString(title, printFont, Brushes.Black, leftMargin, topMargin, new StringFormat());
count = 2;
//打印内容
while (count < linesPerPage &&
((line = streamToPrint.ReadLine()) != null))
{
yPos = topMargin + ( count * printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(line, printFont, Brushes.Black,leftMargin, yPos, new StringFormat());
count++;
}
// If more lines exist, print another page.
if (line != null)
ev.HasMorePages = true;
else
ev.HasMorePages = false;
}
当LINE中有"\t"是打印机会忽列,怎样让打印机遇到"\t"是跳到下一列打印?
如解决,立马结贴(本人在线等).
{
TextFormatFlags flags = TextFormatFlags.Bottom | TextFormatFlags.ExpandTabs;
TextRenderer.DrawText(e.Graphics, "This is some text that will be clipped at the end.", this.Font,
new Rectangle(10, 10, 100, 50), SystemColors.ControlText, flags);
}