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/...

# re: WPF Printing Part 3 – Sizes

Left by Ashish Rathod at 1/22/2015 12:40 PM

Hello sir,

I have use your code and i have one problem is that when i have create one list with huge data and generate document and see data is overflow with same page while data is not overlapping with another page so can you please help me how can i solve this issue ..

Thanks & Regards,
Ashish

Your comment:



 (will not be displayed)


 
 
 
Please add 1 and 1 and type the answer here: