The procedure for calculating X-ray photoelectron spectra in wide ranges of energy losses and viewing angles is developed. The spectra of semi-infinite samples and finite-thickness layers are studied. The angular and energy spectra are analyzed via a solution to the problem for the function of photoelectron emission flux density by means of the invariant embedding method. The energy spectrum is represented in the form of a number of inelastic collisions. The results of exact numerical solution of the problem of multiple photoelectron scattering in solids using the straight-line and small-angle approximations, experimental data, and results of Monte Carlo simulation are compared. Errors in calculations using the straight-line approximation and the advantages of models for describing the spectra in the framework of the small-angle approximation are revealed.