How could we colored the rectangle box components and give then reference designator as in the attached demo file
Your "demo file" looks like somebody took a black&white assembly drawing, imported it into a vector graphics software and painted half-transparent polygons over the existing drawing. I don't exactly understand what you mean with "How could we (...) give then reference designator". The reference designators are defined by the engineer drawing schematics and desinging the PCB. The text sitting centered to the colored polygons also seem to be drawn later on in the vector graphics software.