Where is the generator in a large turbofan of a commercial airliner?
Image source

The generators are usually driven from the Accessory Gearbox. This CAD drawing is from the company that makes accessory gearboxes for the Rolls Royce Trent engines driving the A330 and A350, and it shows the connection of the accessory gearbox to the high pressure rotor. 

 

This picture from the book The Jet Engine by Rolls Royce shows the same arrangement: a bevel gear drives off of the HP spool, then drives another bevel gear connected to the crescent shaped Accessory Gearbox underneath the engine.



The gearbox itself is shown above (from the same book), with the accessories connected to the LP spool:


The Engine Driven hydraulic Pump
Fuel pump
Oil pump
Pneumatic starter, requiring the highest loads and therefore dimensioning the gear strength.
The IDG: Integrated Drive Generator which provides the AC power.




The accessory gearbox contains the engine starter as well, pneumatic for older types and electrical for bleedless engines. The engines are started by turning the HP rotor, and the accessory gearbox must be connected to the HP rotor for this purpose. For this reason, the HP rotor drives the generator and other accessories, although it would be more beneficial for fuel economy to use the LP compressor. Source: The Jet Engine issue 5 by Rolls Royce.