No. Until you attach to a device (to display), there is no such info. There might be various displays with different DPI settings, and even if you know it will be displayed, you don't know which one, and thus can't know DPI till you really render.
So the most sane solution would be to either
1) in the case it is going to be rendered on a canvas (display, printer, whatever), postpone decisions as long as possible till these are clear.
or
2) require user to specify it before rendering.