Deposition of organic thin films with controlled surface density of carboxylic functionalities