Please see my comment to the question and, next time, make sure you provide enough information.
Now, think logically: you either need to know pixel size of the printable area of the page or size in inches + DPI (dots per inch), not both, because these variables depend on each other and can contradict if you take them all. In this case, you are given the printable area in pixels; it is given you in the event arguments when you print a page; this value is
System.Drawing.Printing.PrintPageEventArgs.MarginBounds
:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printpageeventargs.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printpageeventargs.marginbounds.aspx[
^].
You get this parameters when you print a page in your handler of the of event
System.Drawing.Printing.PrintDocument.PrintPage
:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument.printpage.aspx[
^].
In the two last articles referenced above, there are short code samples. If you are doing something else, you are doing it wrong. Again, too bad you did not show essential context of your code.
I would also advice that you develop a single method for rendering some control, form or part of it for rendering on both screen and print page, and pass relevant parameters to this method. You can do it, because in both cases you are dealing with the instance of
System.Drawing.Graphics
:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[
^].
Additionally, you can pass margin and/or other relevant parameters. This will make your printing consistent with on-screen rendering and will help you to avoid repeating of code.
—SA