Synthesising tannin-based coagulants for water and wastewater