By using quantum electrodynamics in a dispersive medium, we describe scattering of plane-wave and twisted photons by a slab made of a helical medium, the helix axis being normal to the slab plane and the medium being not translation invariant in this plane, in general. In the particular cases, the permittivity tensor of a helical medium corresponds to cholesteric liquid crystals, C*-smectics, biaxial chiral nematics and smectics, Q-plates, chiral sculptured thin films, and helical dislocations. Both perturbative and nonperturbative approaches are considered. The explicit expressions for scattering amplitudes, probabilities, and Stokes parameters of photons are found taking into account the form of the photon wave packet. The selection rules are established showing that the helical medium transfers the momentum and the angular momentum to scattered photons. This property can be employed for production of twisted photons with large projection of the total angular momentum. We describe the device for shifting the projection of the total angular momentum of a photon and the principal scheme for signal coding in terms of twisted photons.