Intercept print jobs



I need to make a program that intercept every job before it be
printed, and the program could erase the document or allow to print it
according to a rule or list of users.

Somebody know how I could intercept the pint jobs?
.