An officer or witness to whom, for fees or attendance, anything is due that is taxed in the costs for which there is judgment or decree, may, within ten days after such judgment or decree, lodge in the clerk's office of the court wherein the same is rendered, his fee bills for such fees, or certificate for such attendance. The amount due each officer or witness, for what is so lodged, shall, within said ten days, be noted in the margin of the order or execution book, opposite the entry of the case. An officer or witness whose fees or certificate shall have been so noted shall be paid the same out of the costs, by the person against whom the judgment or decree is; and the right to such payment shall be valid against any assignee of the judgment or decree. When the clerk issues execution in such case, he shall indorse thereon how much of such costs is for each officer or witness whose fees or certificate may be so noted; and the officer collecting such costs shall pay the same accordingly to those entitled thereto. No officer mentioned in this chapter shall be obliged to perform services for any person out of his county, unless payment of his fees for such services be made or secured; nor to perform services for any person against whom he has had fee bills returned, which remain unsatisfied, unless he be secured payment of his fees for the services desired, or performance of such services be directed by a court.