Automatically saving plots in batch mode

I am running a macro in batch mode, and I would like to find a way for that macro to generate some histograms that will be automatically saved as image files (like PDFs). Is there any way to do this?


In your macro simply do:


where is a TCanvas