Automatic paper thickness detection