It is possible, but it is not straight-forward.
Canada's visa requirements for citizens of Pakistan state that you require a visa to visit or transit in Canada. If you do still decide to visit your friend, you will have to apply for a tourist visa. If you simply want to transit in Canada ( less than 48h ) then you can apply for a transit visa. Applying for a transit visa is free of cost.
However, it is very likely that you will not be able to leave the airport on a transit visa.
The only time a US visa will help you is if you have a green card. A B1/B2 visa does not grant you any exemptions in Canada.
Based on the comments below, it seems like you are allowed to exit the airport and the only restriction on your transit visa is the time limit - 48 hours.
Here is a link that should give you more information: