We prove that the asymptotics of ergodic integrals along an invariant foliation of a toral Anosov diffeomorphism, or of a pseudo-Anosov diffeomorphism on a compact orientable surface of higher genus, is determined (up to a logarithmic error) by the action of the diffeomorphism on the cohomology of the surface. As a consequence of our argument and of the results of Giulietti and Liverani [Parabolic dynamics and anisotropic Banach spaces. J. Eur. Math. Soc. (JEMS)21(9) (2019), 2793–2858] on horospherical averages, toral Anosov diffeomorphisms have no Ruelle resonances in the open interval
$(1, e^{h_{\mathrm {top}}})$
.