Hi.
I am having a problem in printing text to printer through printPage event using e.grphics.drawS tring method. On printdocument.p rintPage event When it draws the string, text from the right hand side of the page gets out.. And printer finishes printing...
How will I deal with this problem?
Regards,
Syed Ahmed Hussain
I am having a problem in printing text to printer through printPage event using e.grphics.drawS tring method. On printdocument.p rintPage event When it draws the string, text from the right hand side of the page gets out.. And printer finishes printing...
Code:
void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
Font myFont = new Font("m_svoboda", 14, FontStyle.Underline, GraphicsUnit.Point);
siteHTML = webBrowser1.Document.Body.InnerHtml + webBrowser1.Document.Body.OuterHtml;
float lineHeight = myFont.GetHeight(e.Graphics) + 4;
float yLineTop = e.MarginBounds.Top;
if (yLineTop + lineHeight > e.MarginBounds.Bottom)
{
e.HasMorePages = true;
return;
}
//e.Graphics.DrawString(siteHTML, myFont, Brushes.Black,
// new PointF(e.MarginBounds.Left, yLineTop));
e.Graphics.DrawString(siteHTML, myFont, Brushes.Black, e.PageSettings.PrintableArea.X, e.PageSettings.PrintableArea.Y);
yLineTop += lineHeight;
e.HasMorePages = false;
}
Regards,
Syed Ahmed Hussain
Comment