New Here?
My name is Nir and I'm the founder of Nbd-Tech, this blog is about things that interest me, so you can find posts on productivity, running a software company and obscure technological topics.
If you like what you read you can
subscribe to the blog feed or
follow me on twitter.
In the previous post in the WPF printing series I used a lot of numbers for sizes and positioning, I want to take this post to explain those sizes.
Unlike WinForms where each pixel is really a device pixel in WPF each “pixel” is actually 1/96 of an inch, this means that most of the time each WPF pixel is one pixel on today’s screens (that are usually 96DPI).
For printing this means that when you specify a “pixel” size in WPF this will always translate to the same size on paper, regardless of the actual printer you use.
Also, because most printers are at least 300DPI (usually much more) the printing precision is much more than one pixel, for example, for 600 dpi each real pixel is 0.16 WPF “pixels”, so placing elements at strange locations like this made up coordinate (57.3,55.12) actually makes sense (on the screen this usually leads to blurred controls).
Translating between WPF pixels and common sizes used in printing like inches, millimeters and points is really easy just multiply by the number in the table.
| WPF to … | … to WPF |
Inch | 0.01041666 | 96 |
Mm | 0.26458333 | 3.779527 |
Point | 0.75 | 1.333333 |
In the next post we’ll continue with printing, specifically we’ll write a print preview feature.
posted @ Tuesday, May 19, 2009 5:24 PM