We consider resonant absorption in a spectral line in the outflowing plasma within several tens of Schwarzschild radii from a compact object. We take into account both Doppler and gravitational shifting effects and re-formulate the theory of P-Cygni profiles in these new circumstances. It is found that a spectral line may have multiple absorption and emission components depending on how far the region of interaction is from the compact object and what is the distribution of velocity and opacity. Profiles of spectral lines produced near a neutron star or a black hole can be strongly distorted by Doppler blue-, or redshifting, and gravitational red-shifting. These profiles may have both red-and blue-shifted absorption troughs. The result should be contrasted with classical P-Cygni profiles which consist of red-shifted emission and blue-shifted absorption features.We suggest this property of line profiles to have complicated narrow absorption and emission components in the presence of strong gravity may help to study spectroscopically the innermost parts of an outflow.