This question already has an answer here:
I need to render a model on a transparent background. The models have a light source so they should be casting a shadow on a surface (the XY plane). The purpose for this is to overlay the rendered images (out of blender) on an image of the actual surface, so I want to generate the render including a semi-transparent shadow.
I don´t have any problem rendering the models on transparent background, but I can not make a shadow appear. I tried adding a surface below the model so the shadow can fall on it, but now there's the problem of keeping the surface from rendering.
How can I render the shadow on a transparent background?