Form and meaning
The gerundio compuesto means what English having + past participle means: the action was already over before the main clause happened. Having finished the work, he went home is habiendo terminado el trabajo, se fue a casa, piece for piece. The register matches too: like having finished, it belongs to writing and careful speech; in a chat you would hear después de + infinitive instead.
One warning: the Spanish gerundio is not the English gerund. English swimming is healthy uses an -ing noun, and Spanish never does that: nadar es sano, not nadando es sano. The gerundio only works like an adverb, which is exactly its job here.
Habiendo terminado el trabajo, se fue a casa.
Having finished the work, he went home.
Simple or compound gerundio?
The difference is timing, and English draws the same line between eating and having eaten. The simple gerundio runs alongside the main clause; the compound one is finished before it starts.
Gerundio simple, at the same time
Cenando, vimos la tele.
While having dinner, we watched TV.
Saliendo de casa, la llamó.
As he was leaving the house, he called her.
Gerundio compuesto, finished first
Habiendo cenado, vimos la tele.
Having had dinner, we watched TV.
Habiendo salido de casa, la llamó.
Having left the house, he called her.
What it conveys
Sequence in time
Pure “after”, first A, then B.
Habiendo llegado al hotel, se duchó.
Having arrived at the hotel, he took a shower.
Habiendo escrito el informe, lo envió al director.
Having written the report, she sent it to the director.
Habiendo dicho esto, pasamos al siguiente punto.
Having said that, let us move on to the next point.
Reason
The earlier action is the cause, often best translated with “since” or “because”.
Habiendo vivido en México, hablaba muy bien español.
Having lived in Mexico, he spoke Spanish very well.
Habiendo perdido el tren, llegó tarde.
Having missed the train, he arrived late.
Attaching pronouns
English keeps the object as a separate word: having finished it. Spanish writes the unstressed pronoun onto the end of habiendo. The stress stays on the ie, but the word gets longer and so needs a written accent: habiendo becomes habiéndolo.
Habiéndolo terminado, descansé.
Having finished it, I rested.
Habiéndoselo dicho, se sintió mejor.
Having told him, he felt better.
two pronouns, both attached
Habiéndome levantado temprano, tuve tiempo de sobra.
Having got up early, I had plenty of time.