I would like to measure distance between 0 and 300 mm with a resolution of 1 mm at least.
Could you please tell me if it is possible to do that using an absolute linear magnetic encoder?
Do you plan to make this device yourself? If so, ok, and agree, yes, it can be done.
If you mean to buy a device to do this, why limit yourself to 'magnetic?' There are lots of ways to get absolute linear measurement over such a small distance. More tags to google might be: linear potentiometer, newall scale, linear encoder.