The transformer has a bobbin, a coil assembly and a magnetic core assembly. The bobbin is mounted in the magnetic core assembly and has multiple connecting pins being formed on at least one side of a bottom surface of the bobbin. Each connecting pin has a top surface as a soldering surface that corresponds to a solder pad on a back of a circuit board. At least one fastener is further formed on the bottom surface of the circuit board. Therefore, when the transformer is mounted through the circuit board, the connecting pins are soldered on the back of the circuit board to reduce the total thickness of the combination of the transformer and the circuit board.