Is taking vitamin D supplement the same as sun exposure?

Yes as long as the sun exposure is a minimum of 20 minutes without sunscreen and at least your arms and face are fully exposed.