The problem you're describing is resolution. Typically, printers support a much higher resolution than a screen does, so if you have made assumptions about DPI, for instance, you will see a different output.
It's best to work with Device Independent Pixels, as described
here[
^].