Pulsed gas injection for X-ray spectroscopy of highly charged ions stored in the magnetic trapping mode of an electron beam ion trap