A cam type door closer, comprising: a housing comprising an axial passage and a longitudinal passage in communication with said axial passage, said axial passage being perpendicular to said longitudinal passage, said axial passage running through two opposite sides of said housing; a first piston set mounted in said axial passage of said housing, said first piston set comprising a first piston, a roller, a plug pin, a first spring and a first sealing cap, said first piston comprising an open chamber, a shaft hole and an elongated slot respectively disposed in communication with each other, said open chamber being located in a middle part of said first piston, said shaft hole being located in a distal end of said first piston, said elongated slot being disposed above said open chamber, said first spring being mounted in said axial passage of said housing with one end thereof stopped against said first piston and an opposite end thereof stopped against said first sealing cap, said first sealing cap being mounted in said housing to seal one end of said axial passage; a second piston set mounted in said axial passage of said housing, said second piston set comprising a second piston, a gap compensation device, a second spring and a second sealing cap, said second piston being movably mounted in said shaft hole of said first piston, said second piston comprising a large diameter passage and a small diameter passage in communication with each other, said gap compensation device being mounted in said large diameter passage of said second piston, said second spring being mounted in said axial passage of said housing with one end thereof stopped against said second piston and an opposite end thereof stopped against said second sealing cap, said second sealing cap being mounted in said housing to seal an opposite end of said axial passage; and a drive shaft assembly rotatably inserted into said longitudinal passage of said housing, said drive shaft assembly comprising a shaft and an eccentric cam, said eccentric cam being located on said shaft with one side thereof stopped against said roller of said first piston set and an opposite side thereof stopped against said second piston of said second piston set; characterised in that said eccentric cam comprises two positioning grooves, one said positioning groove being adapted for stopping against said roller of said first piston set when said housing is biased to a first predetermined pivot angle, the other said positioning groove being adapted for stopping against said second piston of said second piston set when said housing is biased to a second predetermined pivot angle. a housing comprising an axial passage and a longitudinal passage in communication with said axial passage, said axial passage being perpendicular to said longitudinal passage, said axial passage running through two opposite sides of said housing; a first piston set mounted in said axial passage of said housing, said first piston set comprising a first piston, a roller, a plug pin, a first spring and a first sealing cap, said first piston comprising an open chamber, a shaft hole and an elongated slot respectively disposed in communication with each other, said open chamber being located in a middle part of said first piston, said shaft hole being located in a distal end of said first piston, said elongated slot being disposed above said open chamber, said first spring being mounted in said axial passage of said housing with one end thereof stopped against said first piston and an opposite end thereof stopped against said first sealing cap, said first sealing cap being mounted in said housing to seal one end of said axial passage; a second piston set mounted in said axial passage of said housing, said second piston set comprising a second piston, a gap compensation device, a second spring and a second sealing cap, said second piston being movably mounted in said shaft hole of said first piston, said second piston comprising a large diameter passage and a small diameter passage in communication with each other, said gap compensation device being mounted in said large diameter passage of said second piston, said second spring being mounted in said axial passage of said housing with one end thereof stopped against said second piston and an opposite end thereof stopped against said second sealing cap, said second sealing cap being mounted in said housing to seal an opposite end of said axial passage; and a drive shaft assembly rotatably inserted into said longitudinal passage of said housing, said drive shaft assembly comprising a shaft and an eccentric cam, said eccentric cam being located on said shaft with one side thereof stopped against said roller of said first piston set and an opposite side thereof stopped against said second piston of said second piston set; characterised in that said eccentric cam comprises two positioning grooves, one said positioning groove being adapted for stopping against said roller of said first piston set when said housing is biased to a first predetermined pivot angle, the other said positioning groove being adapted for stopping against said second piston of said second piston set when said housing is biased to a second predetermined pivot angle.