Printing using e.Graphics.PageUnit = GraphicsUnit.Millimeter doesn't print where it should: it rounds

421 views
Skip to first unread message

Danny Bosschaerts

unread,
Nov 19, 2010, 4:49:00 AM11/19/10
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
When prining against e.Graphics.PageUnit = GraphicsUnit.Millimeter,
the result on the screen (preview) or paper (print) produces unevenly
spaced lines.
I print a list of data from a dataset.
I Debug.Print(Ypos!) of every line, and calculated the delta between
them resulting in exactly the same values up to 4 decimals, so the
lines should space equaly, but is is clear that there is some rounding
up/down (to int(mm) it seems) that is done rather than printing at the
intended location.

These are the values in mm used in DrawString as Y-pos followed by (-
>) what seems to be used and the delta (d=)
87,382 -> 87
91,85239 -> 92 (d=5)
96,32279 -> 96 (d=4)
100,7932 ->101 (d=5
105,2636 -> 105 (d=4)
109,734 ->110 (d=5)
what exactly reflects what I have on screen/paper: each time 2nd line
too far from the previous/too close to the next
Notice that the actual delta should have been 4.47, resulting in
nicely/evenly spaced lines

Before I had all in Inches, and it printed well, but as I had to
convert a lot of mm to inch, I tought it would be logical to work in
mm: I regret it already.

Is this a bug or am I missing something?

PS: working with .net 4.0 VB 2010

Thanks

Arsalan Tamiz

unread,
Nov 22, 2010, 1:58:02 AM11/22/10
to dotnetde...@googlegroups.com
While using drawing routines like DrawString(), are you passing integers as x,y? If yes then you should pass Single values with decimal places this may solve your issue.
Reply all
Reply to author
Forward
0 new messages