OK, this is from poor memory as I haven't done this for years and years, and I can't remember what it looks like etc:
Could be several issues combined so
1. If the front of the door is not hanging correctly when closed, it may mean that the hinge bolts need slacking off (the four behind the A panel). I usually just slacken them off slightly, then move the door by hand, with the door closed and the striker pin at the rear of the door removed from the B pillar (back of door frame). Once you have the door in the correct position, you can tighten the four nuts back up and open and close the door to make sure it doesn't foul anywhere.
2. If the back of the door does not close fully, there is a plate on the B pillar with a striker pin on it, I think there are 2 screws on it which you have to slacken off, this will allow you to position the striker pin correctly.
3. If the door is too close to the A panel, or two far away, you can add or remove the dor shims that Bungle has mentioned. Usually there will be some already there. You can also alter the angle of the door by adding or removing shims from the top or bottom hinge, as necessary.
4. Another issue is that if you have had new door seals fitted, you may need to re-adjust once they have settled in. In some cases it is difficult to close the door with new seals (especially aftermarket ones).
Again, feel free to correct me, as it has been yonks since I did it and I may be totally wrong!