Assuming the Principal is a male and the trainee is female (there are weird people around with weird preferences).....
Someone has to take the initiative.. maybe your friend can escape these situations by avoiding the lone moments, but this pathetic person will still be on the loose, bothering others.
Maybe, trying to take such initiatives she might get into trouble herself. Think before taking your steps (see what kind of person he is - thug type, or just a bully but coward-inside and his contacts - does he know any thugs, bad people, has contacts in police, etc..), but talk with your parents. Of course, recording the conversation secretly is strongly recommended by me too.
Some suggestions from me -
1. She can be diplomatic and somehow manage taking transfer by giving some excuse or strong measure, eg. - record the conversation and threaten him to grant transfer. Usually CAs are pretty cowards. But, he can still bother others, after her.
2. You guys could additionally take photos/ record using pen-cam (sting operation) secretly if possible, later black-mail or, take the case to police.
3. Maybe she can threaten him, by saying if he bothers her like this, she will commit suicide and leave a suicide note blaming him, ruin his life, etc. End it here, everything will be forgetten and forgiven.
4. You and her should talk to your parents along with other trainess of trust (ones not close to the Principal).
5. Talk to his wife (if married), and/ or parents (if around).
6. Talk to a women right organisation/ police in your area.
7. Write to the Chairman/ ICAI, who think a person becomes a GOD after becoming CA (considering the amount of power/ trust they give to CAs in terms of audit/ trainee matters), if you prefer do it anonymously,
Most CAs say and threaten trainees by giving such warnings, but things are not that simple as they think.. You too can do a lot harm.. Prefer taking legal steps in order to keep your case strong..