Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 222111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:05:48+00:00 2026-05-11T19:05:48+00:00

I would like to programmaticaly determine the DPI of a user’s display in order

  • 0

I would like to programmaticaly determine the DPI of a user’s display in order to show a web page at a precise number of units (centimeters/inches). I know it a weird request: it’s for a visualization research project and it’s kind of a control. We currently do it by having the user place a credit card to the screen and match a resizable div (via Mootools) to the real credit card, and voila we can get the DPI and display the page correctly.

Can anyone think of a programmatic way to do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:05:48+00:00Added an answer on May 11, 2026 at 7:05 pm

    If you’re doing this in javascript/mootools, CSS units are your friend. You can specify sizes in inches or centimeters, or even points (1/72 of an inch). If you absolutely need DPI for whatever reason even though you can specify sizes in those units, simply size the “resizable” div you are using to a known size and calculate from the translated pixel size.

    Edit:

    Unfortunately, the CSS units of
    points, cm, and in are not physically
    correct. They are only relatively
    correct. This was the first thing I
    tried until I realized it wasn’t
    working and checked the CSS spec.. to
    my dismay.
    – Brandon Pelfrey

    That’s a good point; browsers tend to fake it by assuming a default DPI (I think 72 or 96) and going with that.

    Well, if you need precision sizing like you’re asking for, you’re out of luck. You’ll never be able to get it without being able to read both the current resolution of the monitor the browser is on and the “viewable screen area” of that monitor. Ain’t no way you’re gonna get that via Javascript.

    I suggest that you make the default assumption that browsers do and size according to the CSS units. You can then allow your users to “adjust the sizing” using the method you mentioned, but only if it’s necessary. Do this with on a separate page with the DPI calculation stored as part of the users session or as a cookie.

    Alternatively, once Microsoft fixes this bug, you could use Silverlight’s “device independent units” for accurate scaling.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A1 is formatted as text and contains a decimal number I would like to
I would like to know about how to delete a folder once user select
I have a UIView in a table view section header that I would like
Using .NET, I would like to programmatically get a list of all the groups
I would like to have a LinkButton programmatically selected. So I have a code
I would like to change the background color of my app programmatically, not IB.
I am trying to programmatically create a view controller. I would like to know
I would like to have a UILocalNotification to execute an action whenever it gets
I have a DataGridView bound to a DataTable. The DataTable is populated from a
I know that the question about turning on/off GPS programatically on android has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.