We present the application of short-pulse laser-driven hard x rays (>40 keV) for the direct density measurement of iron compressed by a laser-driven shock. By using an on-shot calibration of the spectral absorption, we are able to obtain line densities with 5%-10% precision, although the x-ray source is not monochromatic. We also discuss possibilities for increasing the precision, which would be an improvement for equation of state measurements.