Click to See Complete Forum and Search --> : Printing shapes with their exact measurements on paper


hitai
October 1st, 2005, 05:49 AM
In the application i'm making, I would like to print out a line (or any other shapes, I`ll use line here just to make the question simpler). This line that wil be printed must be of an exact length. Let`s say 5 inches. What I`m currently doing in the PrintPage event is something like this


private void printDocument1_PrintPage ( object sender, System.Drawing.Printing.PrintPageEventArgs e )
{
e.Graphics.DrawLine ( new Pen ( Color.Black ),
100, 100,
5 * ( 100 + e.PageBounds.Width / ( e.PageSettings.Bounds.Width / 100 ) ), 100 ) ;
}


this prints a horizontal line of 5 inches, but with some extra length. The offset become greater with a longer line. How do I solve this? I think i should use the PrinterResolution class, but not really sure how (I get strange values with it)