create pdf from histogram loop