pdf generator now working - needs some tidying up doing though.