The spectra of fast-rotating A-type stars have strongly broadened absorption lines. This effect causes blending of the absorption lines, hindering the measurement of the abundances of the elements that are in the stellar photosphere. As the exoplanet transits across its host star, it obscures the stellar spectrum that is emitted from directly behind the planet. We aim to extract this obscured spectrum because it is less affected by rotational broadening, resolving the blending of weak lines of elements that would otherwise remain inaccessible. This allows us to more precisely measure the metal abundances in ultra-hot Jupiter systems, many of which have fast-rotating host stars. We developed a novel method that isolates the stellar spectra behind the planet during a spectral time series, and reconstructs the disc-integrated non-broadened spectrum of the host star. We have systematically tested this method with model-generated spectra of the transit of WASP-189 b across its fast-rotating A-type host star, assessing the effects of limb-darkening, the choice of absorption lines, and the signal-to-noise regime; and demonstrating the sensitivity to photospheric parameters ($T_ eff $ and log $g$) and elemental abundances. We applied the method to observations by the HARPS high-resolution spectrograph. For WASP-189, we obtain the metallicity and photospheric abundances for several species previously not reported in literature, Mg, Ca, and Ti, with a significantly improved accuracy compared to the ordinary broadened stellar spectrum. This method can be generally applied to other transiting systems in which abundance determinations via spectral synthesis are imprecise due to severe line blending. It is important to accurately determine the photospheric properties of exoplanet host stars, as it can provide further insight into the formation and evolution of the planets.