How to control switching of mosfet in PFC boost rectifier using PI controller?
This is typically done with a boost topology. You rectify the input sine, then use the rectified waveform as the reference to a current control loop. Your PWM switch is modulated by this current control loop.

Then there's an outer voltage loop that MUST be much lower bandwidth than the AC ripple, maybe 4-8Hz.  The voltage error for this loop typically drives a multiplier that "programs" the gain of the sinusoidal reference derived above.  It tries to maintain the output voltage at something slightly higher than the max peak AC input voltage.



The output energy is stored in a large bulk cap and can be used directly or supply a following regulation stage.  So you just have to figure out how to do this digitally instead of using an analog controller.

There is lots of information on PFC available from semiconductor vendors like LT, TI, etc.