Whenever notice is required by law to be published in a newspaper by any officer of a county or judicial district, the person for whom the notice is to be given shall pay to the officer, if required, the fees for the publication, in advance. Failure of any officer to publish any notice required by law pertaining to the duties of his office is a misdemeanor.