WPF Printing Part 3 – Sizes

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

Comments on this entry:

# re: WPF Printing Part 3 – Sizes

Left by abhai srivastava at 6/3/2010 6:49 AM

Hi ,

I need to add some validation on document viewer print button , any idea ? I also don't know if some how I override the print function then how to print my fixed document.

Thanks in Advance

Abhai

# re: WPF Printing Part 3 – Sizes

Left by John Shawyer at 9/8/2011 12:04 AM

I was loooking forward to WPF Printing Part 4?????

# re: WPF Printing Part 3 – Sizes

Left by Stan at 10/18/2011 8:28 PM

So was I

# re: WPF Printing Part 3 – Sizes

Left by Adam at 11/15/2011 5:10 PM

John Shawyer, Stan,

Google is your friend.

www.nbdtech.com/...

Your comment:



 (will not be displayed)


 
 
 
Please add 3 and 2 and type the answer here: