Avatar of kmullins5
kmullins5 asked on

How do I get the DPI of my printer using C#?

The question
How do I get the Printer's actual DPI? (Preferably using C# and .net 2.0 or earlier)

A little background information
I am trying to create a print dialog for an application. It needs to be able to print the images into standard photo sizes, which are listed in inches. The user is able to choose their Printer, Paper Size, and Print Quality. Based on the Print Quality, I figure I am going to have to scale my image so it will print to the correct dimensions.

The problem
On my printer, when I use the System.Drawing.Printing.PrintResolution.Kind variable to find the available Printer Resolutions, I get results back like High, Medium, Low, and Draft. When I look at the X and Y values of those, I get results like "-4" and "-2".

After further reading, I found that those are just enumerated standards and are part of the WinGDI.h file. However, I can't find out anywhere what they actually stand for.

So basically, from what I have read, the Print Qualities are just standards and should be as simple as saying Medium is 300 DPI. Unfortunately I can't find any information to back this idea up.
.NET ProgrammingMultimedia ProgrammingC#

Avatar of undefined
Last Comment

8/22/2022 - Mon
Mikael Jansson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Mikael Jansson

forgot to mention that you replace the printer name in the query, in this case it says 'amhome-p01' with your printer name.
actually you can probably replace the foreach section as its only one printer returned.
if you like to run this remotely you remove the single . (dot) in the first codeline after the \\\\ with the computer name you want to check.
/ Mikael

Nothing to add to the tech discussion, just a shout-out for the # of points offered.....
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck